generated from KagChi/postgrestify
-
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.
- Loading branch information
Showing
13 changed files
with
2,822 additions
and
10 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
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
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,11 @@ | ||
import process from "node:process"; | ||
import type { Config } from "drizzle-kit"; | ||
|
||
export default { | ||
dialect: "postgresql", | ||
schema: "./node_modules/@nezuchan/schema/dist/index.js", | ||
out: "./drizzle", | ||
dbCredentials: { | ||
url: process.env.DATABASE_URL! | ||
} | ||
} satisfies Config; |
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,104 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "TierType" AS ENUM('FREE', 'SUPPORTER', 'TIER_1', 'TIER_2', 'TIER_3'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "activation_key" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"tier" "TierType" DEFAULT 'FREE', | ||
"provider" text, | ||
"guild_id" uuid, | ||
"client_id" text, | ||
"start_at" timestamp, | ||
"ends_at" timestamp, | ||
"key" text, | ||
"user_id" uuid, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "crossfade" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"guild_id" uuid, | ||
"client_id" text, | ||
"activated_by" text, | ||
"state" boolean DEFAULT false, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "default_volume" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"guild_id" uuid, | ||
"client_id" text, | ||
"activated_by" text, | ||
"state" integer DEFAULT 100, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "guild" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"guild_id" text, | ||
"client_id" text, | ||
"key_id" text, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "stay_in_vc" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"guild_id" uuid, | ||
"client_id" text, | ||
"activated_by" text, | ||
"state" boolean DEFAULT false, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "user" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"email" text, | ||
"discord_id" text, | ||
"patreon_id" text, | ||
"premium_provider" text DEFAULT 'UNKNOWN', | ||
"premium_tier" "TierType" DEFAULT 'FREE', | ||
"premium_start_at" timestamp DEFAULT now(), | ||
"premium_ends_at" timestamp, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL, | ||
"voted_at" timestamp, | ||
CONSTRAINT "user_discord_id_unique" UNIQUE("discord_id"), | ||
CONSTRAINT "user_patreon_id_unique" UNIQUE("patreon_id") | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "activation_key" ADD CONSTRAINT "activation_key_guild_id_guild_id_fk" FOREIGN KEY ("guild_id") REFERENCES "guild"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "activation_key" ADD CONSTRAINT "activation_key_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "crossfade" ADD CONSTRAINT "crossfade_guild_id_guild_id_fk" FOREIGN KEY ("guild_id") REFERENCES "guild"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "default_volume" ADD CONSTRAINT "default_volume_guild_id_guild_id_fk" FOREIGN KEY ("guild_id") REFERENCES "guild"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "stay_in_vc" ADD CONSTRAINT "stay_in_vc_guild_id_guild_id_fk" FOREIGN KEY ("guild_id") REFERENCES "guild"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
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,32 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "Visibility" AS ENUM('PUBLIC', 'PRIVATE'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "playlist" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"external_id" text, | ||
"user_id" text, | ||
"name" text, | ||
"visibility" "Visibility", | ||
"track_limit" integer, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "playlist_track" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
"playlist_id" uuid, | ||
"external_id" text, | ||
"user_id" text, | ||
"track" json, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "playlist_track" ADD CONSTRAINT "playlist_track_playlist_id_playlist_id_fk" FOREIGN KEY ("playlist_id") REFERENCES "playlist"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
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,2 @@ | ||
ALTER TABLE "playlist" ALTER COLUMN "visibility" SET DEFAULT 'PUBLIC';--> statement-breakpoint | ||
ALTER TABLE "playlist" ALTER COLUMN "track_limit" SET DEFAULT 20; |
Oops, something went wrong.