Skip to content

Instantly share code, notes, and snippets.

@tapkain tapkain/schema.sql
Created Jun 26, 2019

Embed
What would you like to do?
CREATE TABLE "public"."user" (
"id" Character Varying( 128 ) NOT NULL,
PRIMARY KEY ( "id" )
);
CREATE TABLE "public"."post" (
"created_at" Timestamp Without Time Zone,
"id" SERIAL,
"user_id" Character Varying( 128 ) COLLATE "pg_catalog"."default" NOT NULL,
"parent_post_id" Integer,
"scheduled_date" Timestamp Without Time Zone,
PRIMARY KEY ( "id" )
);
ALTER TABLE "public"."post" ADD CONSTRAINT "post_user_id_fkey" FOREIGN KEY ( "user_id" ) REFERENCES "public"."user" ( "id" );
CREATE TABLE "public"."vote" (
"created_at" Timestamp Without Time Zone,
"id" SERIAL,
"user_id" Character Varying( 128 ) NOT NULL,
"post_id" Integer NOT NULL,
"vote" Integer NOT NULL,
PRIMARY KEY ( "id" )
);
CREATE TABLE "public"."content" (
"created_at" Timestamp Without Time Zone,
"modified_at" Timestamp Without Time Zone,
"id" SERIAL,
PRIMARY KEY ( "id" )
);
ALTER TABLE "public"."vote" ADD CONSTRAINT "vote_post_id_fkey" FOREIGN KEY ( "post_id" ) REFERENCES "public"."post" ( "id" );
ALTER TABLE "public"."vote" ADD CONSTRAINT "vote_user_id_fkey" FOREIGN KEY ( "user_id" ) REFERENCES "public"."user" ( "id" );
CREATE TABLE "public"."content_post" (
"id" SERIAL,
"post_id" Integer NOT NULL,
"content_id" Integer NOT NULL,
PRIMARY KEY ( "id" )
);
ALTER TABLE "public"."content_post" ADD CONSTRAINT "content_post_content_id_fkey" FOREIGN KEY ( "content_id" ) REFERENCES "public"."content" ( "id" );
ALTER TABLE "public"."content_post" ADD CONSTRAINT "content_post_post_id_fkey" FOREIGN KEY ( "post_id" ) REFERENCES "public"."post" ( "id" );
CREATE TABLE "public"."blocked_user" (
"id" SERIAL,
"user_id" Character Varying( 128 ) NOT NULL,
"blocked_user_id" Character Varying( 128 ) NOT NULL,
PRIMARY KEY ( "id" )
);
ALTER TABLE "public"."blocked_user" ADD CONSTRAINT "blocked_user_blocked_user_id_fkey" FOREIGN KEY ( "blocked_user_id" ) REFERENCES "public"."user" ( "id" )
ALTER TABLE "public"."blocked_user" ADD CONSTRAINT "blocked_user_user_id_fkey" FOREIGN KEY ( "user_id" ) REFERENCES "public"."user" ( "id" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.