fp/services/migrations-schema/migrations/00116_create-timestamps.sql

210 lines
5.8 KiB
MySQL
Raw Normal View History

2024-12-12 07:23:46 +00:00
-- Table: api.timestamps
-- DROP TABLE IF EXISTS api.timestamps;
CREATE TABLE IF NOT EXISTS api.timestamps
(
id integer NOT NULL,
"time" integer,
creator_id integer,
created_at timestamp(6) without time zone,
updated_at timestamp(6) without time zone,
created_by_id integer,
updated_by_id integer,
CONSTRAINT timestamps_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS api.timestamps
OWNER to postgres;
-- Index: timestamps_created_by_id_fk
-- DROP INDEX IF EXISTS api.timestamps_created_by_id_fk;
CREATE INDEX IF NOT EXISTS timestamps_created_by_id_fk
ON api.timestamps USING btree
(created_by_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_updated_by_id_fk
-- DROP INDEX IF EXISTS api.timestamps_updated_by_id_fk;
CREATE INDEX IF NOT EXISTS timestamps_updated_by_id_fk
ON api.timestamps USING btree
(updated_by_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Table: api.timestamps
-- DROP TABLE IF EXISTS api.timestamps;
CREATE TABLE IF NOT EXISTS api.timestamps
(
id integer NOT NULL,
"time" integer,
creator_id integer,
created_at timestamp(6) without time zone,
updated_at timestamp(6) without time zone,
created_by_id integer,
updated_by_id integer,
CONSTRAINT timestamps_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS api.timestamps
OWNER to postgres;
-- Index: timestamps_created_by_id_fk
-- DROP INDEX IF EXISTS api.timestamps_created_by_id_fk;
CREATE INDEX IF NOT EXISTS timestamps_created_by_id_fk
ON api.timestamps USING btree
(created_by_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_updated_by_id_fk
-- DROP INDEX IF EXISTS api.timestamps_updated_by_id_fk;
CREATE INDEX IF NOT EXISTS timestamps_updated_by_id_fk
ON api.timestamps USING btree
(updated_by_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Table: api.timestamps
-- DROP TABLE IF EXISTS api.timestamps;
CREATE TABLE IF NOT EXISTS api.timestamps
(
id integer NOT NULL,
"time" integer,
creator_id integer,
created_at timestamp(6) without time zone,
updated_at timestamp(6) without time zone,
created_by_id integer,
updated_by_id integer,
CONSTRAINT timestamps_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS api.timestamps
OWNER to postgres;
-- Index: timestamps_created_by_id_fk
-- DROP INDEX IF EXISTS api.timestamps_created_by_id_fk;
CREATE INDEX IF NOT EXISTS timestamps_created_by_id_fk
ON api.timestamps USING btree
(created_by_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_updated_by_id_fk
-- DROP INDEX IF EXISTS api.timestamps_updated_by_id_fk;
CREATE INDEX IF NOT EXISTS timestamps_updated_by_id_fk
ON api.timestamps USING btree
(updated_by_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Table: api.timestamps_upvoters_links
-- DROP TABLE IF EXISTS api.timestamps_upvoters_links;
CREATE TABLE IF NOT EXISTS api.timestamps_upvoters_links
(
id integer NOT NULL,
timestamp_id integer,
user_id integer,
user_order double precision,
CONSTRAINT timestamps_upvoters_links_pkey PRIMARY KEY (id),
CONSTRAINT timestamps_upvoters_links_unique UNIQUE (timestamp_id, user_id),
CONSTRAINT timestamps_upvoters_links_fk FOREIGN KEY (timestamp_id)
REFERENCES api.timestamps (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS api.timestamps_upvoters_links
OWNER to postgres;
-- Index: timestamps_upvoters_links_fk
-- DROP INDEX IF EXISTS api.timestamps_upvoters_links_fk;
CREATE INDEX IF NOT EXISTS timestamps_upvoters_links_fk
ON api.timestamps_upvoters_links USING btree
(timestamp_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_upvoters_links_inv_fk
-- DROP INDEX IF EXISTS api.timestamps_upvoters_links_inv_fk;
CREATE INDEX IF NOT EXISTS timestamps_upvoters_links_inv_fk
ON api.timestamps_upvoters_links USING btree
(user_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_upvoters_links_order_fk
-- DROP INDEX IF EXISTS api.timestamps_upvoters_links_order_fk;
CREATE INDEX IF NOT EXISTS timestamps_upvoters_links_order_fk
ON api.timestamps_upvoters_links USING btree
(user_order ASC NULLS LAST)
TABLESPACE pg_default;
-- Table: api.timestamps_upvoters_links
-- DROP TABLE IF EXISTS api.timestamps_upvoters_links;
CREATE TABLE IF NOT EXISTS api.timestamps_upvoters_links
(
id integer NOT NULL,
timestamp_id integer,
user_id integer,
user_order double precision,
CONSTRAINT timestamps_upvoters_links_pkey PRIMARY KEY (id),
CONSTRAINT timestamps_upvoters_links_unique UNIQUE (timestamp_id, user_id),
CONSTRAINT timestamps_upvoters_links_fk FOREIGN KEY (timestamp_id)
REFERENCES api.timestamps (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS api.timestamps_upvoters_links
OWNER to postgres;
-- Index: timestamps_upvoters_links_fk
-- DROP INDEX IF EXISTS api.timestamps_upvoters_links_fk;
CREATE INDEX IF NOT EXISTS timestamps_upvoters_links_fk
ON api.timestamps_upvoters_links USING btree
(timestamp_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_upvoters_links_inv_fk
-- DROP INDEX IF EXISTS api.timestamps_upvoters_links_inv_fk;
CREATE INDEX IF NOT EXISTS timestamps_upvoters_links_inv_fk
ON api.timestamps_upvoters_links USING btree
(user_id ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: timestamps_upvoters_links_order_fk
-- DROP INDEX IF EXISTS api.timestamps_upvoters_links_order_fk;
CREATE INDEX IF NOT EXISTS timestamps_upvoters_links_order_fk
ON api.timestamps_upvoters_links USING btree
(user_order ASC NULLS LAST)
TABLESPACE pg_default;