-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from rememberry-io/feat/rem-123-integrate-crea…
…te-and-get-stack-on-map Feat/rem 123 integrate create and get stack on map
- Loading branch information
Showing
107 changed files
with
2,005 additions
and
11,942 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "node_type" AS ENUM('stack', 'flashcard'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "invites" ( | ||
"id" uuid DEFAULT gen_random_uuid(), | ||
"reveiver_id" uuid, | ||
"sender_id" uuid, | ||
"peer_id" uuid, | ||
"text" varchar, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "learning_data" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"node_id" uuid, | ||
"user_id" uuid, | ||
"times_learned" integer, | ||
"last_learned" date, | ||
"learning_status" integer DEFAULT 0, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "maps" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"user_id" uuid NOT NULL, | ||
"peer_id" uuid, | ||
"name" varchar NOT NULL, | ||
"description" varchar DEFAULT '' NOT NULL, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "media" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"flashcard_id" uuid, | ||
"frontside_media_link" varchar, | ||
"frontside_media_positioning" varchar, | ||
"backside_media_link" varchar, | ||
"backside_media_positioning" varchar, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "nodes" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"map_id" uuid NOT NULL, | ||
"frontside" varchar NOT NULL, | ||
"backside" varchar NOT NULL, | ||
"x_position" double precision NOT NULL, | ||
"y_position" double precision NOT NULL, | ||
"parent_node_id" uuid, | ||
"node_type" "node_type" NOT NULL, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "peers" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"name" varchar NOT NULL, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "session" ( | ||
"id" varchar PRIMARY KEY NOT NULL, | ||
"user_id" uuid NOT NULL, | ||
"expires_at" timestamp with time zone NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "users" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"username" varchar NOT NULL, | ||
"email" varchar NOT NULL, | ||
"password" varchar NOT NULL, | ||
CONSTRAINT "users_username_unique" UNIQUE("username"), | ||
CONSTRAINT "users_email_unique" UNIQUE("email") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "users_peers" ( | ||
"user_id" uuid, | ||
"peer_id" uuid, | ||
"is_peer_admin" boolean DEFAULT false NOT NULL | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "invites" ADD CONSTRAINT "invites_reveiver_id_users_id_fk" FOREIGN KEY ("reveiver_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "invites" ADD CONSTRAINT "invites_sender_id_users_id_fk" FOREIGN KEY ("sender_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "invites" ADD CONSTRAINT "invites_peer_id_peers_id_fk" FOREIGN KEY ("peer_id") REFERENCES "peers"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "learning_data" ADD CONSTRAINT "learning_data_node_id_nodes_id_fk" FOREIGN KEY ("node_id") REFERENCES "nodes"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "learning_data" ADD CONSTRAINT "learning_data_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "maps" ADD CONSTRAINT "maps_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "maps" ADD CONSTRAINT "maps_peer_id_peers_id_fk" FOREIGN KEY ("peer_id") REFERENCES "peers"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "media" ADD CONSTRAINT "media_flashcard_id_nodes_id_fk" FOREIGN KEY ("flashcard_id") REFERENCES "nodes"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "nodes" ADD CONSTRAINT "nodes_map_id_maps_id_fk" FOREIGN KEY ("map_id") REFERENCES "maps"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "nodes" ADD CONSTRAINT "nodes_parent_node_id_nodes_id_fk" FOREIGN KEY ("parent_node_id") REFERENCES "nodes"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "users_peers" ADD CONSTRAINT "users_peers_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "users_peers" ADD CONSTRAINT "users_peers_peer_id_peers_id_fk" FOREIGN KEY ("peer_id") REFERENCES "peers"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.