add db schema
This commit is contained in:
parent
9afedd4a02
commit
3743d52ac3
73
db_schema.sql
Normal file
73
db_schema.sql
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
-- Database export via SQLPro (https://www.sqlprostudio.com/)
|
||||||
|
-- Exported by camille at 27-01-2025 12:25.
|
||||||
|
-- WARNING: This file may contain descructive statements such as DROPs.
|
||||||
|
-- Please ensure that you are running the script at the proper location.
|
||||||
|
|
||||||
|
|
||||||
|
-- BEGIN TABLE public.instances
|
||||||
|
DROP TABLE IF EXISTS public.instances CASCADE;
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.instances (
|
||||||
|
id bigint DEFAULT nextval('insances_sampleid_seq'::regclass) NOT NULL,
|
||||||
|
instance character varying NOT NULL,
|
||||||
|
record_update_by bigint,
|
||||||
|
record_updated_at timestamp without time zone,
|
||||||
|
vote integer DEFAULT 1 NOT NULL,
|
||||||
|
PRIMARY KEY(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- END TABLE public.instances
|
||||||
|
|
||||||
|
-- BEGIN TABLE public.receipts
|
||||||
|
DROP TABLE IF EXISTS public.receipts CASCADE;
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.receipts (
|
||||||
|
id bigint DEFAULT nextval('receipts_sampleid_seq'::regclass) NOT NULL,
|
||||||
|
instance_id bigint NOT NULL,
|
||||||
|
updated_by bigint,
|
||||||
|
updated_at timestamp without time zone,
|
||||||
|
original_link character varying NOT NULL,
|
||||||
|
image_filename character varying,
|
||||||
|
PRIMARY KEY(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- END TABLE public.receipts
|
||||||
|
|
||||||
|
-- BEGIN TABLE public.users
|
||||||
|
DROP TABLE IF EXISTS public.users CASCADE;
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.users (
|
||||||
|
id bigint DEFAULT nextval('users_sampleid_seq'::regclass) NOT NULL,
|
||||||
|
username character varying NOT NULL,
|
||||||
|
fullname character varying,
|
||||||
|
fedi_address character varying NOT NULL,
|
||||||
|
active boolean DEFAULT true NOT NULL,
|
||||||
|
PRIMARY KEY(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- END TABLE public.users
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.instances
|
||||||
|
ADD CONSTRAINT instances_users_fk
|
||||||
|
FOREIGN KEY (record_update_by)
|
||||||
|
REFERENCES public.users (id);
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.receipts
|
||||||
|
ADD CONSTRAINT instance_id_fkey
|
||||||
|
FOREIGN KEY (instance_id)
|
||||||
|
REFERENCES public.instances (id)
|
||||||
|
ON DELETE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.receipts
|
||||||
|
ADD CONSTRAINT update_by_fkey
|
||||||
|
FOREIGN KEY (updated_by)
|
||||||
|
REFERENCES public.users (id);
|
Loading…
x
Reference in New Issue
Block a user