Skip to content

Commit

Permalink
fix: db files (#9)
Browse files Browse the repository at this point in the history
Fix DB SQL
  • Loading branch information
lennartkloock committed Feb 22, 2024
1 parent 6eb98e2 commit 82d28d9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode/
target/
8 changes: 8 additions & 0 deletions database/emotes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ CREATE TABLE "emotes" (
CREATE INDEX "emotes_owner_id_index" ON "emotes" ("owner_id");
CREATE UNIQUE INDEX "emotes_ticket_id_unique" ON "emotes" ("ticket_id");

CREATE TABLE "emote_attributions" (
"emote_id" uuid NOT NULL, -- Ref: emotes.id -> On Delete Cascade
"user_id" uuid NOT NULL, -- Ref: users.id -> On Delete Cascade
PRIMARY KEY ("emote_id", "user_id")
);

CREATE INDEX "emote_attributions_user_id_index" ON "emote_attributions" ("user_id");

CREATE TABLE "emote_files" (
"emote_id" uuid NOT NULL, -- Ref: emotes.id -> DO NOTHING
"file_id" uuid NOT NULL, -- Ref: files.id -> DO NOTHING
Expand Down
7 changes: 2 additions & 5 deletions database/product.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ CREATE TABLE "product_codes" (
"updated_at" timestamptz NOT NULL DEFAULT 'NOW()'
);

CREATE TABLE "product_code_product_associations" (
CREATE TABLE "product_code_association_product" (
"product_code_id" uuid NOT NULL, -- Ref: product_codes.id -> On Delete Cascade
"associated_product_id" uuid NOT NULL, -- Ref: products.id -> DO NOTHING
PRIMARY KEY ("product_code_id", "associated_product_id")
);

CREATE INDEX "product_product_associations_associated_product_id_index" ON "product_product_associations" ("associated_product_id");
CREATE INDEX "product_code_association_product_associated_product_id_index" ON "product_code_association_product" ("associated_product_id");

CREATE TYPE "product_purchase_status" AS ENUM ('PENDING', 'COMPLETED', 'REFUNDED', 'FAILED');

Expand All @@ -98,7 +98,6 @@ CREATE INDEX "product_purchases_product_id_index" ON "product_purchases" ("produ
CREATE INDEX "product_purchases_user_id_index" ON "product_purchases" ("user_id");
CREATE INDEX "product_purchases_recipient_id_index" ON "product_purchases" ("recipient_id");
CREATE INDEX "product_purchases_status_index" ON "product_purchases" ("status");
CREATE INDEX "product_purchases_subscription_id_index" ON "product_purchases" ("subscription_id");

CREATE TYPE "product_subscription_status" AS ENUM ('ACTIVE', 'INACTIVE', 'FAILED');

Expand All @@ -116,5 +115,3 @@ CREATE INDEX "product_subscriptions_product_id_index" ON "product_subscriptions"
CREATE INDEX "product_subscriptions_user_id_index" ON "product_subscriptions" ("user_id");
CREATE INDEX "product_subscriptions_status_index" ON "product_subscriptions" ("status");
CREATE INDEX "product_subscriptions_next_payment_due_index" ON "product_subscriptions" ("next_payment_due");

CREATE INDEX "product_subscription_purchases_purchase_id_index" ON "product_subscription_purchases" ("purchase_id");
2 changes: 1 addition & 1 deletion database/ticket.sql → database/tickets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ CREATE INDEX "ticket_files_file_id_index" ON "ticket_files" ("file_id");
CREATE TABLE "ticket_members" (
"ticket_id" uuid NOT NULL, -- Ref: tickets.id -> On Delete Cascade
"user_id" uuid NOT NULL, -- Ref: users.id -> On Delete Cascade
"kind" support_ticket_member_kind NOT NULL,
"kind" ticket_member_kind NOT NULL,
"voted" boolean NOT NULL DEFAULT false,
"notifications" boolean NOT NULL DEFAULT true,
PRIMARY KEY ("ticket_id", "user_id")
Expand Down
5 changes: 3 additions & 2 deletions database/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ CREATE INDEX "users_entitled_cache_invalidate_product_ids_index" ON "users" USIN
CREATE INDEX "users_active_badge_id_index" ON "users" ("active_badge_id");
CREATE INDEX "users_active_paint_id_index" ON "users" ("active_paint_id");
CREATE INDEX "users_active_profile_picture_id_index" ON "users" ("active_profile_picture_id");
CREATE INDEX "users_active_connection_id_index" ON "users" ("active_connection_id");

CREATE TYPE "connection_platform" AS ENUM ('DISCORD', 'TWITCH', 'YOUTUBE', 'KICK');

CREATE TABLE "user_connections" (
"id" uuid PRIMARY KEY,
Expand Down Expand Up @@ -89,7 +90,7 @@ CREATE TYPE "user_editor_state" AS ENUM ('ACTIVE', 'INVITED', 'BLOCKED_INVITE');
CREATE TABLE "user_editors" (
"user_id" uuid NOT NULL, -- Ref: users.id -> On Delete Cascade
"editor_id" uuid NOT NULL, -- Ref: users.id -> On Delete Cascade
"state" user_editor_state NOT NULL DEFAULT true,
"state" user_editor_state NOT NULL DEFAULT 'INVITED',
"permissions" int8 NOT NULL DEFAULT 0,
"updated_at" timestamptz NOT NULL DEFAULT 'NOW()',
PRIMARY KEY ("user_id", "editor_id")
Expand Down

0 comments on commit 82d28d9

Please sign in to comment.