please note: play newbie here
System Info:
OS: Arch Linux x64
- 4.12.3-1-ARCH
Database: MariaDB
- mysql Ver 15.1 Distrib 10.1.25-MariaDB, for Linux (x86_64) using readline 5.1
Problem:
I am attemptig to create a database with tables from associated model classes, where the index/id key is to long.
Error:
An evolution has not been applied properly. Please check the problem and resolve it manually before marking it as resolved.
We got the following error: Index column size too large. The maximum column size is 767 bytes. [ERROR:1709, SQLSTATE:HY000], while trying to run this SQL script:
# --- Rev:1,Ups - 7feba1a
create table address (
address_id bigint auto_increment not null,
unit_number varchar(255),
street_name varchar(255),
community_name varchar(255),
is_community tinyint(1) default 0,
constraint pk_address primary key (address_id)
);
create table user (
user_id bigint auto_increment not null,
name varchar(255),
surname varchar(255),
password varchar(255),
email varchar(255),
cell_number varchar(255),
email_verified tinyint(1) default 0,
crsftoken varchar(255),
token varchar(255),
constraint pk_user primary key (user_id)
);
A few models listed below:
Address model
@Entity
public class Address extends Model {
@Id
@Constraints.Required
@GeneratedValue
private Long addressId;
@Constraints.Required
private String unitNumber;
@Constraints.Required
private String streetName;
private String communityName;
private Boolean isCommunity;
public static Finder<String, Address> find = new Finder<String, Address>(Address.class);
User model:
@Entity
public class User extends Model {
@Id
@Constraints.MinLength(10)
@Constraints.MaxLength(10)
@GeneratedValue
private Long userId;
private String name;
private String surname;
@Constraints.Required
private String password;
@Constraints.Email
@Constraints.Required
private String email;
@Constraints.Required
@Constraints.Pattern("[0]\\d{2}[- ]{0,1}\\d{3}[- ]{0,1}\\d{4}")
private String cellNumber;
private Boolean emailVerified = false;
private String CRSFToken;
public static Finder<String, User> find = new Finder<String, User>(User.class);
What I have discovered:
Researching this error, it seems to imply that I should:
1. use the innoDB engine (used by default in MariaDB)
2. set the innodb_large_prefix
3. use the barracuda file format
4. set table (with innoDB engine) row formatting with ROW_FORMAT
to DYNAMIC
or COMPRESSED
These solutions were suggested on SO:
and an independent blog:
- here (most helpful of all)
More information:
I attempted setting these:
MariaDB [(none)]> CREATE DATABASE eatalotdb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> set GLOBAL storage_engine='InnoDb';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> set GLOBAL innodb_large_prefix = ON;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> set global innodb_file_format = BARRACUDA;
Query OK, 0 rows affected (0.00 sec)
I could not set row format, since no tables existed at the moment, but when tables are created by the Evolutions
SQL script, the error below is presented.
Question:
I have ended up at page 3 of Google search results, yet not found a solution. How can I resolve this error?
p.s. As a side question, I am struggling to find information and documentation on Play! Framework, besides the standard documentation provided by Play!, where else can I learn more with examples, understanding, etc?