105 lines
3.0 KiB
MySQL
105 lines
3.0 KiB
MySQL
|
-- Table: api.vtubers_toy_links
|
||
|
|
||
|
-- DROP TABLE IF EXISTS api.vtubers_toy_links;
|
||
|
|
||
|
CREATE TABLE IF NOT EXISTS api.vtubers_toy_links
|
||
|
(
|
||
|
id integer NOT NULL,
|
||
|
vtuber_id integer,
|
||
|
toy_id integer,
|
||
|
vtuber_order double precision,
|
||
|
CONSTRAINT vtubers_toy_links_pkey PRIMARY KEY (id),
|
||
|
CONSTRAINT vtubers_toy_links_unique UNIQUE (vtuber_id, toy_id),
|
||
|
CONSTRAINT vtubers_toy_links_fk FOREIGN KEY (vtuber_id)
|
||
|
REFERENCES api.vtubers (id) MATCH SIMPLE
|
||
|
ON UPDATE NO ACTION
|
||
|
ON DELETE CASCADE,
|
||
|
CONSTRAINT vtubers_toy_links_inv_fk FOREIGN KEY (toy_id)
|
||
|
REFERENCES api.toys (id) MATCH SIMPLE
|
||
|
ON UPDATE NO ACTION
|
||
|
ON DELETE CASCADE
|
||
|
)
|
||
|
|
||
|
TABLESPACE pg_default;
|
||
|
|
||
|
ALTER TABLE IF EXISTS api.vtubers_toy_links
|
||
|
OWNER to postgres;
|
||
|
-- Index: vtubers_toy_links_fk
|
||
|
|
||
|
-- DROP INDEX IF EXISTS api.vtubers_toy_links_fk;
|
||
|
|
||
|
CREATE INDEX IF NOT EXISTS vtubers_toy_links_fk
|
||
|
ON api.vtubers_toy_links USING btree
|
||
|
(vtuber_id ASC NULLS LAST)
|
||
|
TABLESPACE pg_default;
|
||
|
-- Index: vtubers_toy_links_inv_fk
|
||
|
|
||
|
-- DROP INDEX IF EXISTS api.vtubers_toy_links_inv_fk;
|
||
|
|
||
|
CREATE INDEX IF NOT EXISTS vtubers_toy_links_inv_fk
|
||
|
ON api.vtubers_toy_links USING btree
|
||
|
(toy_id ASC NULLS LAST)
|
||
|
TABLESPACE pg_default;
|
||
|
-- Index: vtubers_toy_links_order_inv_fk
|
||
|
|
||
|
-- DROP INDEX IF EXISTS api.vtubers_toy_links_order_inv_fk;
|
||
|
|
||
|
CREATE INDEX IF NOT EXISTS vtubers_toy_links_order_inv_fk
|
||
|
ON api.vtubers_toy_links USING btree
|
||
|
(vtuber_order ASC NULLS LAST)
|
||
|
TABLESPACE pg_default;
|
||
|
|
||
|
|
||
|
|
||
|
-- also adding vtubers_toys_links
|
||
|
|
||
|
-- Table: api.vtubers_toys_links
|
||
|
|
||
|
-- DROP TABLE IF EXISTS api.vtubers_toys_links;
|
||
|
|
||
|
CREATE TABLE IF NOT EXISTS api.vtubers_toys_links
|
||
|
(
|
||
|
id integer NOT NULL,
|
||
|
vtuber_id integer,
|
||
|
toy_id integer,
|
||
|
toy_order double precision,
|
||
|
CONSTRAINT vtubers_toys_links_pkey PRIMARY KEY (id),
|
||
|
CONSTRAINT vtubers_toys_links_unique UNIQUE (vtuber_id, toy_id),
|
||
|
CONSTRAINT vtubers_toys_links_fk FOREIGN KEY (vtuber_id)
|
||
|
REFERENCES api.vtubers (id) MATCH SIMPLE
|
||
|
ON UPDATE NO ACTION
|
||
|
ON DELETE CASCADE,
|
||
|
CONSTRAINT vtubers_toys_links_inv_fk FOREIGN KEY (toy_id)
|
||
|
REFERENCES api.toys (id) MATCH SIMPLE
|
||
|
ON UPDATE NO ACTION
|
||
|
ON DELETE CASCADE
|
||
|
)
|
||
|
|
||
|
TABLESPACE pg_default;
|
||
|
|
||
|
ALTER TABLE IF EXISTS api.vtubers_toys_links
|
||
|
OWNER to postgres;
|
||
|
-- Index: vtubers_toys_links_fk
|
||
|
|
||
|
-- DROP INDEX IF EXISTS api.vtubers_toys_links_fk;
|
||
|
|
||
|
CREATE INDEX IF NOT EXISTS vtubers_toys_links_fk
|
||
|
ON api.vtubers_toys_links USING btree
|
||
|
(vtuber_id ASC NULLS LAST)
|
||
|
TABLESPACE pg_default;
|
||
|
-- Index: vtubers_toys_links_inv_fk
|
||
|
|
||
|
-- DROP INDEX IF EXISTS api.vtubers_toys_links_inv_fk;
|
||
|
|
||
|
CREATE INDEX IF NOT EXISTS vtubers_toys_links_inv_fk
|
||
|
ON api.vtubers_toys_links USING btree
|
||
|
(toy_id ASC NULLS LAST)
|
||
|
TABLESPACE pg_default;
|
||
|
-- Index: vtubers_toys_links_order_fk
|
||
|
|
||
|
-- DROP INDEX IF EXISTS api.vtubers_toys_links_order_fk;
|
||
|
|
||
|
CREATE INDEX IF NOT EXISTS vtubers_toys_links_order_fk
|
||
|
ON api.vtubers_toys_links USING btree
|
||
|
(toy_order ASC NULLS LAST)
|
||
|
TABLESPACE pg_default;
|