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

     1  CREATE TABLE magic
     2  (
     3    id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
     4    id_two int NOT NULL,
     5    id_three int,
     6    bit_zero bit,
     7    bit_one bit NULL,
     8    bit_two bit NOT NULL,
     9    bit_three bit NULL DEFAULT 0,
    10    bit_four bit NULL DEFAULT 1,
    11    bit_five bit NOT NULL DEFAULT 0,
    12    bit_six bit NOT NULL DEFAULT 1,
    13    string_zero VARCHAR(1),
    14    string_one VARCHAR(1) NULL,
    15    string_two VARCHAR(1) NOT NULL,
    16    string_three VARCHAR(1) NULL DEFAULT 'a',
    17    string_four VARCHAR(1) NOT NULL DEFAULT 'b',
    18    string_five VARCHAR(1000),
    19    string_six VARCHAR(1000) NULL,
    20    string_seven VARCHAR(1000) NOT NULL,
    21    string_eight VARCHAR(1000) NULL DEFAULT 'abcdefgh',
    22    string_nine VARCHAR(1000) NOT NULL DEFAULT 'abcdefgh',
    23    string_ten VARCHAR(1000) NULL DEFAULT '',
    24    string_eleven VARCHAR(1000) NOT NULL DEFAULT '',
    25    big_int_zero bigint,
    26    big_int_one bigint NULL,
    27    big_int_two bigint NOT NULL,
    28    big_int_three bigint NULL DEFAULT 111111,
    29    big_int_four bigint NOT NULL DEFAULT 222222,
    30    big_int_five bigint NULL DEFAULT 0,
    31    big_int_six bigint NOT NULL DEFAULT 0,
    32    int_zero int,
    33    int_one int NULL,
    34    int_two int NOT NULL,
    35    int_three int NULL DEFAULT 333333,
    36    int_four int NOT NULL DEFAULT 444444,
    37    int_five int NULL DEFAULT 0,
    38    int_six int NOT NULL DEFAULT 0,
    39    float_zero float,
    40    float_one float,
    41    float_two float(24),
    42    float_three float(24),
    43    float_four float(24) NULL,
    44    float_five float(24) NOT NULL,
    45    float_six float(24) NULL DEFAULT 1.1,
    46    float_seven float(24) NOT NULL DEFAULT 1.1,
    47    float_eight float(24) NULL DEFAULT 0.0,
    48    float_nine float(24) NULL DEFAULT 0.0,
    49    bytea_zero binary NOT NULL,
    50    bytea_one binary NOT NULL,
    51    bytea_two binary NOT NULL,
    52    bytea_three binary NOT NULL DEFAULT CONVERT(VARBINARY(MAX),'a'),
    53    bytea_four binary NOT NULL DEFAULT CONVERT(VARBINARY(MAX),'b'),
    54    bytea_five binary(100) NOT NULL DEFAULT CONVERT(VARBINARY(MAX),'abcdefghabcdefghabcdefgh'),
    55    bytea_six binary(100) NOT NULL DEFAULT  CONVERT(VARBINARY(MAX),'hgfedcbahgfedcbahgfedcba'),
    56    bytea_seven binary NOT NULL DEFAULT CONVERT(VARBINARY(MAX),''),
    57    bytea_eight binary NOT NULL DEFAULT CONVERT(VARBINARY(MAX),''),
    58    time_zero timestamp NOT NULL,
    59    time_one date,
    60    time_eleven date NULL,
    61    time_twelve date NOT NULL,
    62    time_fifteen date NULL DEFAULT '19990108',
    63    time_sixteen date NOT NULL DEFAULT '1999-01-08'
    64  );
    65  GO
    66  
    67  CREATE TABLE magicest
    68  (
    69    id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
    70    kk float NULL,
    71    ll float NOT NULL,
    72    mm tinyint NULL,
    73    nn tinyint NOT NULL,
    74    oo bit NULL,
    75    pp bit NOT NULL,
    76    qq smallint NULL,
    77    rr smallint NOT NULL,
    78    ss int NULL,
    79    tt int NOT NULL,
    80    uu bigint NULL,
    81    vv bigint NOT NULL,
    82    ww float NULL,
    83    xx float NOT NULL,
    84    yy float NULL,
    85    zz float NOT NULL,
    86    aaa double precision NULL,
    87    bbb double precision NOT NULL,
    88    ccc real NULL,
    89    ddd real NOT NULL,
    90    ggg date NULL,
    91    hhh date NOT NULL,
    92    iii datetime NULL,
    93    jjj datetime NOT NULL,
    94    kkk timestamp NOT NULL,
    95    mmm binary NOT NULL,
    96    nnn binary NOT NULL,
    97    ooo varbinary(100) NOT NULL,
    98    ppp varbinary(100) NOT NULL,
    99    qqq varbinary NOT NULL,
   100    rrr varbinary NOT NULL,
   101    www varbinary(max) NOT NULL,
   102    xxx varbinary(max) NOT NULL,
   103    yyy varchar(100) NULL,
   104    zzz varchar(100) NOT NULL,
   105    aaaa char NULL,
   106    bbbb char NOT NULL,
   107    cccc VARCHAR(MAX) NULL,
   108    dddd VARCHAR(MAX) NOT NULL,
   109    eeee tinyint NULL,
   110    ffff tinyint NOT NULL
   111  );
   112  GO
   113  
   114  create table owner
   115  (
   116    id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
   117    name varchar(255) not null
   118  );
   119  GO
   120  
   121  create table cats
   122  (
   123    id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
   124    name varchar(255) not null,
   125    owner_id int
   126  );
   127  GO
   128  
   129  ALTER TABLE cats ADD CONSTRAINT cats_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES owner(id);
   130  GO
   131  
   132  create table toys
   133  (
   134    id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
   135    name varchar(255) not null
   136  );
   137  GO
   138  
   139  create table cat_toys
   140  (
   141    cat_id int not null references cats (id),
   142    toy_id int not null references toys (id),
   143    primary key (cat_id, toy_id)
   144  );
   145  GO
   146  
   147  create table dog_toys
   148  (
   149    dog_id int not null,
   150    toy_id int not null,
   151    primary key (dog_id, toy_id)
   152  );
   153  GO
   154  
   155  create table dragon_toys
   156  (
   157    dragon_id varchar(100),
   158    toy_id varchar(100),
   159    primary key (dragon_id, toy_id)
   160  );
   161  GO
   162  
   163  create table spider_toys
   164  (
   165    spider_id varchar(100) primary key,
   166    name varchar(100)
   167  );
   168  GO
   169  
   170  create table pals
   171  (
   172    pal varchar(100) primary key,
   173    name varchar(100)
   174  );
   175  GO
   176  
   177  create table friend
   178  (
   179    friend varchar(100) primary key,
   180    name varchar(100)
   181  );
   182  GO
   183  
   184  create table bro
   185  (
   186    bros varchar(100) primary key,
   187    name varchar(100)
   188  );
   189  GO
   190  
   191  create table enemies
   192  (
   193    enemies varchar(100) primary key,
   194    name varchar(100)
   195  );
   196  GO
   197  
   198  create table chocolate
   199  (
   200    dog varchar(100) primary key
   201  );
   202  GO
   203  
   204  create table waffles
   205  (
   206    cat varchar(100) primary key
   207  );
   208  GO
   209  
   210  create table tigers
   211  (
   212    id binary primary key,
   213    name binary NOT NULL
   214  );
   215  GO
   216  
   217  create table elephants
   218  (
   219    id binary primary key,
   220    name binary not null,
   221    tiger_id binary NOT NULL unique
   222  );
   223  GO
   224  
   225  ALTER TABLE elephants ADD CONSTRAINT elephants_tiger_id_fkey FOREIGN KEY (tiger_id) REFERENCES tigers(id);
   226  GO
   227  
   228  create table wolves
   229  (
   230    id binary primary key,
   231    name binary not null,
   232    tiger_id binary not null unique
   233  );
   234  GO
   235  
   236  ALTER TABLE wolves ADD CONSTRAINT wolves_tiger_id_fkey FOREIGN KEY (tiger_id) REFERENCES tigers(id);
   237  GO
   238  
   239  create table ants
   240  (
   241    id binary primary key,
   242    name binary not null,
   243    tiger_id binary not null
   244  );
   245  GO
   246  
   247  ALTER TABLE ants ADD CONSTRAINT ants_tiger_id_fkey FOREIGN KEY (tiger_id) REFERENCES tigers(id);
   248  GO
   249  
   250  create table worms
   251  (
   252    id binary primary key,
   253    name binary not null,
   254    tiger_id binary NOT NULL
   255  );
   256  GO
   257  
   258  ALTER TABLE worms ADD CONSTRAINT worms_tiger_id_fkey FOREIGN KEY (tiger_id) REFERENCES tigers(id);
   259  GO
   260  
   261  create table byte_pilots
   262  (
   263    id binary primary key not null,
   264    name varchar(255)
   265  );
   266  GO
   267  
   268  create table byte_airports
   269  (
   270    id binary primary key not null,
   271    name varchar(255)
   272  );
   273  GO
   274  
   275  create table byte_languages
   276  (
   277    id binary primary key not null,
   278    name varchar(255)
   279  );
   280  GO
   281  
   282  create table byte_jets
   283  (
   284    id binary primary key not null,
   285    name varchar(255),
   286    byte_pilot_id binary unique NOT NULL,
   287    byte_airport_id binary NOT NULL
   288  );
   289  GO
   290  
   291  ALTER TABLE byte_jets ADD CONSTRAINT byte_jets_byte_pilot_id_fkey FOREIGN KEY (byte_pilot_id) REFERENCES byte_pilots(id);
   292  GO
   293  ALTER TABLE byte_jets ADD CONSTRAINT byte_jets_byte_airport_id_fkey FOREIGN KEY (byte_airport_id) REFERENCES byte_airports(id);
   294  GO
   295  
   296  create table byte_pilot_languages
   297  (
   298    byte_pilot_id binary not null,
   299    byte_language_id binary not null
   300  );
   301  GO
   302  
   303  ALTER TABLE byte_pilot_languages ADD CONSTRAINT byte_pilot_languages_pkey PRIMARY KEY (byte_pilot_id,byte_language_id);
   304  GO
   305  
   306  ALTER TABLE byte_pilot_languages ADD CONSTRAINT byte_pilot_languages_byte_pilot_id_fkey FOREIGN KEY (byte_pilot_id) REFERENCES byte_pilots(id);
   307  GO
   308  ALTER TABLE byte_pilot_languages ADD CONSTRAINT byte_pilot_languages_byte_language_id_fkey FOREIGN KEY (byte_language_id) REFERENCES byte_languages(id);
   309  GO
   310  
   311  create table cars
   312  (
   313    id integer not null,
   314    name VARCHAR(MAX),
   315    primary key (id)
   316  );
   317  GO
   318  
   319  create table car_cars
   320  (
   321    car_id integer not null,
   322    awesome_car_id integer not null,
   323    relation VARCHAR(MAX) not null,
   324    primary key (car_id, awesome_car_id)
   325  );
   326  GO
   327  
   328  ALTER TABLE car_cars ADD CONSTRAINT car_id_fkey FOREIGN KEY (car_id) REFERENCES cars(id);
   329  GO
   330  ALTER TABLE car_cars ADD CONSTRAINT awesome_car_id_fkey FOREIGN KEY (awesome_car_id) REFERENCES cars(id);
   331  GO
   332  
   333  create table trucks
   334  (
   335    id integer not null,
   336    parent_id integer,
   337    name VARCHAR(MAX),
   338    primary key (id)
   339  );
   340  GO
   341  
   342  ALTER TABLE trucks ADD CONSTRAINT parent_id_fkey FOREIGN KEY (parent_id) REFERENCES trucks(id);
   343  GO
   344  
   345  CREATE TABLE race
   346  (
   347    id integer PRIMARY KEY NOT NULL,
   348    race_date datetime,
   349    track VARCHAR(MAX)
   350  );
   351  GO
   352  
   353  CREATE TABLE race_results
   354  (
   355    id integer PRIMARY KEY NOT NULL,
   356    race_id integer,
   357    name VARCHAR(MAX)
   358  );
   359  GO
   360  
   361  ALTER TABLE race_results ADD CONSTRAINT race_id_fkey FOREIGN KEY (race_id) REFERENCES race(id);
   362  GO
   363  
   364  CREATE TABLE race_result_scratchings
   365  (
   366    id integer PRIMARY KEY NOT NULL,
   367    results_id integer NOT NULL,
   368    name VARCHAR(MAX) NOT NULL
   369  );
   370  GO
   371  
   372  ALTER TABLE race_result_scratchings ADD CONSTRAINT results_id_fkey FOREIGN KEY (results_id) REFERENCES race_results(id);
   373  GO
   374  
   375  CREATE TABLE pilots
   376  (
   377    id integer NOT NULL,
   378    name VARCHAR(MAX) NOT NULL
   379  );
   380  GO
   381  
   382  ALTER TABLE pilots ADD CONSTRAINT pilot_pkey PRIMARY KEY (id);
   383  GO
   384  
   385  CREATE TABLE jets
   386  (
   387    id integer NOT NULL,
   388    pilot_id integer NOT NULL,
   389    age integer NOT NULL,
   390    name VARCHAR(MAX) NOT NULL,
   391    color VARCHAR(MAX) NOT NULL
   392  );
   393  GO
   394  
   395  ALTER TABLE jets ADD CONSTRAINT jet_pkey PRIMARY KEY (id);
   396  GO
   397  ALTER TABLE jets ADD CONSTRAINT pilots_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
   398  GO
   399  
   400  CREATE TABLE languages
   401  (
   402    id integer NOT NULL,
   403    language VARCHAR(MAX) NOT NULL
   404  );
   405  GO
   406  
   407  ALTER TABLE languages ADD CONSTRAINT language_pkey PRIMARY KEY (id);
   408  GO
   409  
   410  -- Join table
   411  CREATE TABLE pilot_languages
   412  (
   413    pilot_id integer NOT NULL,
   414    language_id integer NOT NULL,
   415    uniqueid uniqueidentifier NOT NULL,
   416  );
   417  GO
   418  
   419  -- Composite primary key
   420  ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_pkey PRIMARY KEY (pilot_id, language_id);
   421  GO
   422  ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
   423  GO
   424  ALTER TABLE pilot_languages ADD CONSTRAINT languages_fkey FOREIGN KEY (language_id) REFERENCES languages(id);
   425  GO
   426  
   427  CREATE TABLE powers_of_two
   428  (
   429    vid int NOT NULL IDENTITY(1,1),
   430    name varchar(255) NOT NULL DEFAULT '',
   431    machine_name varchar(255) NOT NULL,
   432    description VARCHAR(MAX),
   433    hierarchy tinyint NOT NULL DEFAULT '0',
   434    module varchar(255) NOT NULL DEFAULT '',
   435    weight int NOT NULL DEFAULT '0',
   436    PRIMARY KEY (vid),
   437    CONSTRAINT machine_name UNIQUE(machine_name)
   438  );
   439  GO
   440  
   441  -- Previously the generated code had a naming clash when a table was called 'updates'
   442  CREATE TABLE updates
   443  (
   444    id integer PRIMARY KEY NOT NULL
   445  );
   446  GO