drop table if exists access_tokens;
drop table if exists accounts;
drop table if exists linked_accounts;
drop table if exists refresh_tokens;
drop table if exists type_salad_boolean_types;
drop table if exists type_salad_character_types;
drop table if exists type_salad_numeric_arbitrary_precision_types;
drop table if exists type_salad_numeric_floating_point_types;
drop table if exists type_salad_numeric_integer_types;
drop table if exists type_salad_numeric_serial_types;
drop table if exists type_salad_uuid_types;

create table access_tokens (
	id varchar(36) not null primary key,
	name varchar(50),
	description varchar(4000),
	expires_at timestamp with time zone,
    expires_in interval,

	created_at timestamp with time zone not null,
	created_by_account_id varchar(36),
	deleted_at timestamp with time zone,
	deleted_by_account_id varchar(36),
	updated_at timestamp with time zone,
	updated_by_account_id varchar(36),
	owner_account_id varchar(36)
);

create table accounts (
	id varchar(36) not null primary key,
	name varchar(50),
	email varchar(255),
	metadata json,
	linked_account_ids varchar(36)[],
	
	created_at timestamp with time zone not null,
	created_by_account_id varchar(36),
	deleted_at timestamp with time zone,
	deleted_by_account_id varchar(36),
	updated_at timestamp with time zone,
	updated_by_account_id varchar(36),
	owner_account_id varchar(36)
);

create table linked_accounts (
	id varchar(36) not null primary key,
	type varchar(25) not null,
	provider varchar(25) not null,
	provider_uid varchar(50),
	metadata json,
	
	created_at timestamp with time zone not null,
	created_by_account_id varchar(36),
	deleted_at timestamp with time zone,
	deleted_by_account_id varchar(36),
	updated_at timestamp with time zone,
	updated_by_account_id varchar(36),
	owner_account_id varchar(36)	
);

create table refresh_tokens (
	id varchar(36) not null primary key
);

create table type_salad_boolean_types (
	col_1 boolean
);

create table type_salad_character_types (
	col_1 character varying(25),
	col_2 varchar(25),
	col_3 bpchar,
	col_4 text
);

create table type_salad_numeric_arbitrary_precision_types (
	id varchar(36) not null primary key,
	col_2 numeric,
	col_3 numeric(3),
	col_4 numeric(3, 1)
);

create table type_salad_numeric_floating_point_types (
	id varchar(36) not null primary key,
	col_2 real,
	col_3 double precision
);

create table type_salad_numeric_integer_types (
	id varchar(36) not null primary key,
	col_2 smallint,
	col_3 integer,
	col_4 bigint
);

create table type_salad_numeric_serial_types (
	id varchar(36) not null primary key,
	col_2 smallserial,
	col_3 serial,
	col_4 bigserial
);

create table type_salad_uuid_types (
	id uuid not null primary key default gen_random_uuid()
);
