github.com/Ali-iotechsys/sqlboiler/v4@v4.0.0-20221208124957-6aec9a5f1f71/drivers/sqlboiler-psql/driver/testdatabase.sql (about)

     1  -- Don't forget to maintain order here, foreign keys!
     2  drop table if exists video_tags;
     3  drop table if exists tags;
     4  drop table if exists videos;
     5  drop table if exists sponsors;
     6  drop table if exists users;
     7  drop table if exists type_monsters;
     8  drop view if exists user_videos;
     9  drop view if exists type_monsters_v;
    10  drop materialized view if exists type_monsters_mv;
    11  
    12  drop type if exists workday;
    13  create type workday as enum('monday', 'tuesday', 'wednesday', 'thursday', 'friday');
    14  
    15  drop domain if exists uint3;
    16  create domain uint3 as numeric check(value >= 0 and value < power(2::numeric, 3::numeric));
    17  
    18  create table users (
    19  	id serial primary key not null,
    20  	email_validated  bool null default false,
    21  	primary_email    varchar(100) unique null
    22  );
    23  
    24  comment on column users.email_validated is 'Has the email address been tested?';
    25  comment on column users.primary_email is 'The user''s preferred email address.
    26  
    27  Use this to send emails to the user.';
    28  
    29  
    30  create table sponsors (
    31  	id serial primary key not null
    32  );
    33  
    34  create table videos (
    35  	id serial primary key not null,
    36  
    37  	user_id int not null,
    38  	sponsor_id int unique,
    39  
    40  	foreign key (user_id) references users (id),
    41  	foreign key (sponsor_id) references sponsors (id)
    42  );
    43  
    44  create table tags (
    45  	id serial primary key not null
    46  );
    47  
    48  create table video_tags (
    49  	video_id int not null,
    50  	tag_id int not null,
    51  
    52  	primary key (video_id, tag_id),
    53  	foreign key (video_id) references videos (id),
    54  	foreign key (tag_id) references tags (id)
    55  );
    56  
    57  drop type if exists my_int_array;
    58  create domain my_int_array as int[];
    59  
    60  create table type_monsters (
    61  	id serial primary key not null,
    62  
    63  	enum_use        workday not null,
    64  	enum_nullable   workday,
    65  
    66  	bool_zero   bool,
    67  	bool_one    bool null,
    68  	bool_two    bool not null,
    69  	bool_three  bool null default false,
    70  	bool_four   bool null default true,
    71  	bool_five   bool not null default false,
    72  	bool_six    bool not null default true,
    73  
    74  	string_zero   varchar(1),
    75  	string_one    varchar(1) null,
    76  	string_two    varchar(1) not null,
    77  	string_three  varchar(1) null default 'a',
    78  	string_four   varchar(1) not null default 'b',
    79  	string_five   varchar(1000),
    80  	string_six    varchar(1000) null,
    81  	string_seven  varchar(1000) not null,
    82  	string_eight  varchar(1000) null default 'abcdefgh',
    83  	string_nine   varchar(1000) not null default 'abcdefgh',
    84  	string_ten    varchar(1000) null default '',
    85  	string_eleven varchar(1000) not null default '',
    86  
    87  	nonbyte_zero   char(1),
    88  	nonbyte_one    char(1) null,
    89  	nonbyte_two    char(1) not null,
    90  	nonbyte_three  char(1) null default 'a',
    91  	nonbyte_four   char(1) not null default 'b',
    92  	nonbyte_five   char(1000),
    93  	nonbyte_six    char(1000) null,
    94  	nonbyte_seven  char(1000) not null,
    95  	nonbyte_eight  char(1000) null default 'a',
    96  	nonbyte_nine   char(1000) not null default 'b',
    97  
    98  	byte_zero   "char",
    99  	byte_one    "char" null,
   100  	byte_two    "char" null default 'a',
   101  	byte_three  "char" not null,
   102  	byte_four   "char" not null default 'b',
   103  
   104  	big_int_zero  bigint,
   105  	big_int_one   bigint null,
   106  	big_int_two   bigint not null,
   107  	big_int_three bigint null default 111111,
   108  	big_int_four  bigint not null default 222222,
   109  	big_int_five  bigint null default 0,
   110  	big_int_six   bigint not null default 0,
   111  
   112  	int_zero  int,
   113  	int_one   int null,
   114  	int_two   int not null,
   115  	int_three int null default 333333,
   116  	int_four  int not null default 444444,
   117  	int_five  int null default 0,
   118  	int_six   int not null default 0,
   119  
   120  	float_zero  decimal,
   121  	float_one   numeric,
   122  	float_two   numeric(2,1),
   123  	float_three numeric(2,1),
   124  	float_four  numeric(2,1) null,
   125  	float_five  numeric(2,1) not null,
   126  	float_six   numeric(2,1) null default 1.1,
   127  	float_seven numeric(2,1) not null default 1.1,
   128  	float_eight numeric(2,1) null default 0.0,
   129  	float_nine  numeric(2,1) null default 0.0,
   130  
   131  	bytea_zero  bytea,
   132  	bytea_one   bytea null,
   133  	bytea_two   bytea not null,
   134  	bytea_three bytea not null default 'a',
   135  	bytea_four  bytea null default 'b',
   136  	bytea_five  bytea not null default 'abcdefghabcdefghabcdefgh',
   137  	bytea_six   bytea null default 'hgfedcbahgfedcbahgfedcba',
   138  	bytea_seven bytea not null default '',
   139  	bytea_eight bytea not null default '',
   140  
   141  	time_zero      timestamp,
   142  	time_one       date,
   143  	time_two       timestamp null default null,
   144  	time_three     timestamp null,
   145  	time_four      timestamp not null,
   146  	time_five      timestamp null default '1999-01-08 04:05:06.789',
   147  	time_six       timestamp null default '1999-01-08 04:05:06.789 -8:00',
   148  	time_seven     timestamp null default 'January 8 04:05:06 1999 PST',
   149  	time_eight     timestamp not null default '1999-01-08 04:05:06.789',
   150  	time_nine      timestamp not null default '1999-01-08 04:05:06.789 -8:00',
   151  	time_ten       timestamp not null default 'January 8 04:05:06 1999 PST',
   152  	time_eleven    date null,
   153  	time_twelve    date not null,
   154  	time_thirteen  date null default '1999-01-08',
   155  	time_fourteen  date null default 'January 8, 1999',
   156  	time_fifteen   date null default '19990108',
   157  	time_sixteen   date not null default '1999-01-08',
   158  	time_seventeen date not null default 'January 8, 1999',
   159  	time_eighteen  date not null default '19990108',
   160  
   161  	uuid_zero  uuid,
   162  	uuid_one   uuid null,
   163  	uuid_two   uuid null default null,
   164  	uuid_three uuid not null,
   165  	uuid_four  uuid null default '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
   166  	uuid_five  uuid not null default '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
   167  
   168  	integer_default integer default '5'::integer,
   169  	varchar_default varchar(1000) default 5::varchar,
   170  	timestamp_notz  timestamp without time zone default (now() at time zone 'utc'),
   171  	timestamp_tz    timestamp with time zone default (now() at time zone 'utc'),
   172  	interval_nnull  interval not null default '21 days',
   173  	interval_null   interval null default '23 hours',
   174  
   175  	json_null   json null,
   176  	json_nnull  json not null,
   177  	jsonb_null  jsonb null,
   178  	jsonb_nnull jsonb not null,
   179  
   180  	box_null  box null,
   181  	box_nnull box not null,
   182  
   183  	cidr_null  cidr null,
   184  	cidr_nnull cidr not null,
   185  
   186  	circle_null  circle null,
   187  	circle_nnull circle not null,
   188  
   189  	double_prec_null  double precision null,
   190  	double_prec_nnull double precision not null,
   191  
   192  	inet_null  inet null,
   193  	inet_nnull inet not null,
   194  
   195  	line_null  line null,
   196  	line_nnull line not null,
   197  
   198  	lseg_null  lseg null,
   199  	lseg_nnull lseg not null,
   200  
   201  	macaddr_null  macaddr null,
   202  	macaddr_nnull macaddr not null,
   203  
   204  	money_null  money null,
   205  	money_nnull money not null,
   206  
   207  	path_null  path null,
   208  	path_nnull path not null,
   209  
   210  	pg_lsn_null  pg_lsn null,
   211  	pg_lsn_nnull pg_lsn not null,
   212  
   213  	point_null  point NULL,
   214  	point_nnull point NOT NULL,
   215  
   216  	polygon_null  polygon NULL,
   217  	polygon_nnull polygon NOT NULL,
   218  
   219  	tsquery_null   tsquery NULL,
   220  	tsquery_nnull  tsquery NOT NULL,
   221  	tsvector_null  tsvector NULL,
   222  	tsvector_nnull tsvector NOT NULL,
   223  
   224  	txid_null  txid_snapshot NULL,
   225  	txid_nnull txid_snapshot NOT NULL,
   226  
   227  	xml_null  xml NULL,
   228  	xml_nnull xml NOT NULL,
   229  
   230  	intarr_null      integer[] null,
   231  	intarr_nnull     integer[] not null,
   232  	boolarr_null     boolean[] null,
   233  	boolarr_nnull    boolean[] not null,
   234  	varchararr_null  varchar[] null,
   235  	varchararr_nnull varchar[] not null,
   236  	decimalarr_null  decimal[] null,
   237  	decimalarr_nnull decimal[] not null,
   238  	byteaarr_null    bytea[] null,
   239  	byteaarr_nnull   bytea[] not null,
   240  	jsonbarr_null    jsonb[] null,
   241  	jsonbarr_nnull   jsonb[] not null,
   242  	jsonarr_null     json[] null,
   243  	jsonarr_nnull    json[] not null,
   244  
   245  	customarr_null   my_int_array null,
   246  	customarr_nnull  my_int_array not null,
   247  
   248      domainuint3_nnull uint3 not null,
   249  
   250      base text null,
   251  
   252      generated_nnull text NOT NULL GENERATED ALWAYS AS (UPPER(base)) STORED,
   253      generated_null text NULL GENERATED ALWAYS AS (UPPER(base)) STORED
   254  );
   255  
   256  create view user_videos as 
   257  select u.id user_id, v.id video_id, v.sponsor_id sponsor_id
   258  from users u
   259  inner join videos v on v.user_id = u.id;
   260  
   261  create view type_monsters_v as select * from type_monsters; 
   262  create materialized view type_monsters_mv as select * from type_monsters_v;