github.com/Ali-iotechsys/sqlboiler/v4@v4.0.0-20221208124957-6aec9a5f1f71/testdata/mysql_test_schema.sql (about)

     1  CREATE TABLE event_one (
     2    id     serial PRIMARY KEY NOT NULL,
     3    name   VARCHAR(255),
     4    face   enum('happy','sad','bitter'),
     5    mood   enum('happy','sad','bitter'),
     6    day    enum('monday','tuesday','wednesday')
     7  );
     8  
     9  CREATE TABLE magic (
    10    id         int PRIMARY KEY NOT NULL AUTO_INCREMENT,
    11    id_two     int NOT NULL,
    12    id_three   int,
    13    bool_zero  bool,
    14    bool_one   bool NULL,
    15    bool_two   bool NOT NULL,
    16    bool_three bool NULL DEFAULT FALSE,
    17    bool_four  bool NULL DEFAULT TRUE,
    18    bool_five  bool NOT NULL DEFAULT FALSE,
    19    bool_six   bool NOT NULL DEFAULT TRUE,
    20    string_zero   VARCHAR(1),
    21    string_one    VARCHAR(1) NULL,
    22    string_two    VARCHAR(1) NOT NULL,
    23    string_three  VARCHAR(1) NULL DEFAULT 'a',
    24    string_four   VARCHAR(1) NOT NULL DEFAULT 'b',
    25    string_five   VARCHAR(1000),
    26    string_six    VARCHAR(1000) NULL,
    27    string_seven  VARCHAR(1000) NOT NULL,
    28    string_eight  VARCHAR(1000) NULL DEFAULT 'abcdefgh',
    29    string_nine   VARCHAR(1000) NOT NULL DEFAULT 'abcdefgh',
    30    string_ten    VARCHAR(1000) NULL DEFAULT '',
    31    string_eleven VARCHAR(1000) NOT NULL DEFAULT '',
    32    big_int_zero  bigint,
    33    big_int_one   bigint NULL,
    34    big_int_two   bigint NOT NULL,
    35    big_int_three bigint NULL DEFAULT 111111,
    36    big_int_four  bigint NOT NULL DEFAULT 222222,
    37    big_int_five  bigint NULL DEFAULT 0,
    38    big_int_six   bigint NOT NULL DEFAULT 0,
    39    int_zero  int,
    40    int_one   int NULL,
    41    int_two   int NOT NULL,
    42    int_three int NULL DEFAULT 333333,
    43    int_four  int NOT NULL DEFAULT 444444,
    44    int_five  int NULL DEFAULT 0,
    45    int_six   int NOT NULL DEFAULT 0,
    46    float_zero  float,
    47    float_one   float,
    48    float_two   float(2,1),
    49    float_three float(2,1),
    50    float_four  float(2,1) NULL,
    51    float_five  float(2,1) NOT NULL,
    52    float_six   float(2,1) NULL DEFAULT 1.1,
    53    float_seven float(2,1) NOT NULL DEFAULT 1.1,
    54    float_eight float(2,1) NULL DEFAULT 0.0,
    55    float_nine  float(2,1) NULL DEFAULT 0.0,
    56    bytea_zero  binary,
    57    bytea_one   binary NULL,
    58    bytea_two   binary NOT NULL,
    59    bytea_three binary NOT NULL DEFAULT 'a',
    60    bytea_four  binary NULL DEFAULT 'b',
    61    bytea_five  binary(100) NOT NULL DEFAULT 'abcdefghabcdefghabcdefgh',
    62    bytea_six   binary(100) NULL DEFAULT 'hgfedcbahgfedcbahgfedcba',
    63    bytea_seven binary NOT NULL DEFAULT '',
    64    bytea_eight binary NOT NULL DEFAULT '',
    65    time_zero   timestamp,
    66    time_one    date,
    67    time_two    timestamp NULL DEFAULT NULL,
    68    time_three  timestamp NULL,
    69    time_five   timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    70    time_nine   timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    71    time_eleven date NULL,
    72    time_twelve date NOT NULL,
    73    time_fifteen date NULL DEFAULT '19990108',
    74    time_sixteen date NOT NULL DEFAULT '1999-01-08'
    75  );
    76  
    77  CREATE TABLE magicest (
    78    id   int primary key not null auto_increment,
    79    aa   json NULL,
    80    bb   json NOT NULL,
    81    kk   double precision NULL,
    82    ll   double precision NOT NULL,
    83    mm   tinyint NULL,
    84    nn   tinyint NOT NULL,
    85    oo   tinyint(1) NULL,
    86    pp   tinyint(1) NOT NULL,
    87    qq   smallint NULL,
    88    rr   smallint NOT NULL,
    89    ss   mediumint NULL,
    90    tt   mediumint NOT NULL,
    91    uu   bigint NULL,
    92    vv   bigint NOT NULL,
    93    ww   float NULL,
    94    xx   float NOT NULL,
    95    yy   double NULL,
    96    zz   double NOT NULL,
    97    aaa  double precision NULL,
    98    bbb  double precision NOT NULL,
    99    ccc  real NULL,
   100    ddd  real NOT NULL,
   101    eee  boolean NULL,
   102    fff  boolean NOT NULL,
   103    ggg  date NULL,
   104    hhh  date NOT NULL,
   105    iii  datetime NULL,
   106    jjj  datetime NOT NULL,
   107    kkk  timestamp NULL,
   108    lll  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   109    mmm  binary NULL,
   110    nnn  binary NOT NULL,
   111    ooo  varbinary(100) NULL,
   112    ppp  varbinary(100) NOT NULL,
   113    qqq  tinyblob NULL,
   114    rrr  tinyblob NOT NULL,
   115    sss  blob NULL,
   116    ttt  blob NOT NULL,
   117    uuu  mediumblob NULL,
   118    vvv  mediumblob NOT NULL,
   119    www  longblob NULL,
   120    xxx  longblob NOT NULL,
   121    yyy  varchar(100) NULL,
   122    zzz  varchar(100) NOT NULL,
   123    aaaa char NULL,
   124    bbbb char NOT NULL,
   125    cccc text NULL,
   126    dddd text NOT NULL,
   127    eeee tinyint(2) NULL,
   128    ffff tinyint(2) NOT NULL
   129  );
   130  
   131  create table owner (
   132    id    int primary key not null auto_increment,
   133    name  varchar(255) not null
   134  );
   135  
   136  create table cats (
   137    id    int primary key not null auto_increment,
   138    name     varchar(255) not null,
   139    owner_id int references owner (id)
   140  );
   141  
   142  create table toys (
   143    id    int primary key not null auto_increment,
   144    name  varchar(255) not null
   145  );
   146  
   147  create table cat_toys (
   148    cat_id int not null references cats (id),
   149    toy_id int not null references toys (id),
   150    primary key (cat_id, toy_id)
   151  );
   152  
   153  create table dog_toys (
   154    dog_id int not null,
   155    toy_id int not null,
   156    primary key (dog_id, toy_id)
   157  );
   158  
   159  create table dragon_toys (
   160    dragon_id varchar(100),
   161    toy_id    varchar(100),
   162    primary key (dragon_id, toy_id)
   163  );
   164  
   165  create table spider_toys (
   166    spider_id varchar(100) primary key,
   167    name      varchar(100)
   168  );
   169  
   170  create table pals (
   171    pal varchar(100) primary key,
   172    name varchar(100)
   173  );
   174  
   175  create table friend (
   176    friend varchar(100) primary key,
   177    name varchar(100)
   178  );
   179  
   180  create table bro (
   181    bros varchar(100) primary key,
   182    name varchar(100)
   183  );
   184  
   185  create table enemies (
   186    enemies varchar(100) primary key,
   187    name varchar(100)
   188  );
   189  
   190  create table chocolate (
   191    dog varchar(100) primary key
   192  );
   193  
   194  create table waffles (
   195    cat varchar(100) primary key
   196  );
   197  
   198  create table tigers (
   199    id    binary primary key,
   200    name  binary null
   201  );
   202  
   203  create table elephants (
   204    id        binary primary key,
   205    name      binary not null,
   206    tiger_id  binary null unique,
   207    foreign key (tiger_id) references tigers (id)
   208  );
   209  
   210  create table wolves (
   211    id        binary primary key,
   212    name      binary not null,
   213    tiger_id  binary not null unique,
   214    foreign key (tiger_id) references tigers (id)
   215  );
   216  
   217  create table ants (
   218    id        binary primary key,
   219    name      binary not null,
   220    tiger_id  binary not null,
   221    foreign key (tiger_id) references tigers (id)
   222  );
   223  
   224  create table worms (
   225    id        binary primary key,
   226    name      binary not null,
   227    tiger_id  binary null,
   228    foreign key (tiger_id) references tigers (id)
   229  );
   230  
   231  create table byte_pilots (
   232    id   binary primary key not null,
   233    name varchar(255)
   234  );
   235  
   236  create table byte_airports (
   237    id   binary primary key not null,
   238    name varchar(255)
   239  );
   240  
   241  create table byte_languages (
   242    id   binary primary key not null,
   243    name varchar(255)
   244  );
   245  
   246  create table byte_jets (
   247    id              binary primary key not null,
   248    name            varchar(255),
   249    byte_pilot_id   binary unique,
   250    byte_airport_id binary,
   251  
   252    foreign key (byte_pilot_id) references byte_pilots (id),
   253    foreign key (byte_airport_id) references byte_airports (id)
   254  );
   255  
   256  create table byte_pilot_languages (
   257    byte_pilot_id    binary not null,
   258    byte_language_id binary not null,
   259  
   260    primary key (byte_pilot_id, byte_language_id),
   261    foreign key (byte_pilot_id) references byte_pilots (id),
   262    foreign key (byte_language_id) references byte_languages (id)
   263  );
   264  
   265  create table cars (
   266    id integer not null,
   267    name text,
   268    primary key (id)
   269  );
   270  
   271  create table car_cars (
   272    car_id integer not null,
   273    awesome_car_id integer not null,
   274    relation text not null,
   275    primary key (car_id, awesome_car_id),
   276    foreign key (car_id) references cars(id),
   277    foreign key (awesome_car_id) references cars(id)
   278  );
   279  
   280  create table trucks (
   281    id integer not null,
   282    parent_id integer,
   283    name text,
   284    primary key (id),
   285    foreign key (parent_id) references trucks(id)
   286  );
   287  
   288  CREATE TABLE race (
   289      id integer PRIMARY KEY NOT NULL,
   290      race_date timestamp,
   291      track text
   292  );
   293  
   294  CREATE TABLE race_results (
   295      id integer PRIMARY KEY NOT NULL,
   296      race_id integer,
   297      name text,
   298      foreign key (race_id) references race(id)
   299  );
   300  
   301  CREATE TABLE race_result_scratchings (
   302      id integer PRIMARY KEY NOT NULL,
   303      results_id integer NOT NULL,
   304      name text NOT NULL,
   305      foreign key (results_id) references race_results(id)
   306  );
   307  
   308  CREATE TABLE pilots (
   309    id integer NOT NULL,
   310    name text NOT NULL
   311  );
   312  
   313  ALTER TABLE pilots ADD CONSTRAINT pilot_pkey PRIMARY KEY (id);
   314  
   315  CREATE TABLE jets (
   316    id integer NOT NULL,
   317    pilot_id integer NOT NULL,
   318    age integer NOT NULL,
   319    name text NOT NULL,
   320    color text NOT NULL
   321  );
   322  
   323  ALTER TABLE jets ADD CONSTRAINT jet_pkey PRIMARY KEY (id);
   324  ALTER TABLE jets ADD CONSTRAINT pilots_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
   325  
   326  CREATE TABLE languages (
   327    id integer NOT NULL,
   328    language text NOT NULL
   329  );
   330  
   331  ALTER TABLE languages ADD CONSTRAINT language_pkey PRIMARY KEY (id);
   332  
   333  -- Join table
   334  CREATE TABLE pilot_languages (
   335    pilot_id integer NOT NULL,
   336    language_id integer NOT NULL
   337  );
   338  
   339  -- Composite primary key
   340  ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_pkey PRIMARY KEY (pilot_id, language_id);
   341  ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
   342  ALTER TABLE pilot_languages ADD CONSTRAINT languages_fkey FOREIGN KEY (language_id) REFERENCES languages(id);
   343  
   344  CREATE TABLE powers_of_two (
   345    vid int(10) unsigned NOT NULL AUTO_INCREMENT,
   346    name varchar(255) NOT NULL DEFAULT '',
   347    machine_name varchar(255) NOT NULL DEFAULT '',
   348    description longtext,
   349    hierarchy tinyint(3) unsigned NOT NULL DEFAULT '0',
   350    module varchar(255) NOT NULL DEFAULT '',
   351    weight int(11) NOT NULL DEFAULT '0',
   352    PRIMARY KEY (vid),
   353    UNIQUE KEY machine_name (machine_name),
   354    KEY list (weight,name)
   355  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
   356  
   357  -- Previously the generated code had a naming clash when a table was called 'updates'
   358  CREATE TABLE updates (
   359      id integer PRIMARY KEY NOT NULL
   360  );