Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
feat: add database package
Browse files Browse the repository at this point in the history
  • Loading branch information
ijsKoud committed Apr 9, 2024
1 parent 08b0607 commit 1eebe85
Show file tree
Hide file tree
Showing 33 changed files with 922 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"**/*.{js,jsx,ts,tsx}": [() => "pnpm lint -- --fix", "prettier --write"]
};
3 changes: 0 additions & 3 deletions .lintstagedrc.json

This file was deleted.

6 changes: 6 additions & 0 deletions packages/database/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["../../.eslintrc.json"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
}
}
11 changes: 11 additions & 0 deletions packages/database/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Config } from "drizzle-kit";

export default {
schema: "./src/lib/schema.ts",
out: "./drizzle",
driver: "pg",
verbose: true,
dbCredentials: {
connectionString: process.env.DATABASE_URL ?? ""
}
} satisfies Config;
4 changes: 4 additions & 0 deletions packages/database/drizzle/0000_fine_unus.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS "guild" (
"id" varchar PRIMARY KEY NOT NULL,
"webhook" varchar NOT NULL
);
1 change: 1 addition & 0 deletions packages/database/drizzle/0001_chemical_mad_thinker.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "guild" ADD COLUMN "created_at" timestamp DEFAULT now() NOT NULL;
1 change: 1 addition & 0 deletions packages/database/drizzle/0002_aromatic_lethal_legion.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "guild" ADD COLUMN "webhook_type" varchar NOT NULL;
13 changes: 13 additions & 0 deletions packages/database/drizzle/0003_fearless_zemo.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS "guild_form" (
"id" varchar PRIMARY KEY NOT NULL,
"guild_id" varchar NOT NULL,
"repository" varchar NOT NULL,
"forum_post" varchar NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "guild_form" ADD CONSTRAINT "guild_form_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 $$;
7 changes: 7 additions & 0 deletions packages/database/drizzle/0004_lame_yellow_claw.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE "guild_form" DROP CONSTRAINT "guild_form_guild_id_guild_id_fk";
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "guild_form" ADD CONSTRAINT "guild_form_guild_id_guild_id_fk" FOREIGN KEY ("guild_id") REFERENCES "guild"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
37 changes: 37 additions & 0 deletions packages/database/drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"id": "c6cef27b-3f11-48c4-855d-4cb30d1d8ae5",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "5",
"dialect": "pg",
"tables": {
"guild": {
"name": "guild",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"webhook": {
"name": "webhook",
"type": "varchar",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
44 changes: 44 additions & 0 deletions packages/database/drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"id": "752a208f-24c5-4021-ae35-7f57b06f939d",
"prevId": "c6cef27b-3f11-48c4-855d-4cb30d1d8ae5",
"version": "5",
"dialect": "pg",
"tables": {
"guild": {
"name": "guild",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"webhook": {
"name": "webhook",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
50 changes: 50 additions & 0 deletions packages/database/drizzle/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"id": "c7a71c97-00d5-4a81-9376-a2a2bc29a4df",
"prevId": "752a208f-24c5-4021-ae35-7f57b06f939d",
"version": "5",
"dialect": "pg",
"tables": {
"guild": {
"name": "guild",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"webhook": {
"name": "webhook",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"webhook_type": {
"name": "webhook_type",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
105 changes: 105 additions & 0 deletions packages/database/drizzle/meta/0003_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"id": "9aa70381-a243-4ac1-9ea4-812c17258eaf",
"prevId": "c7a71c97-00d5-4a81-9376-a2a2bc29a4df",
"version": "5",
"dialect": "pg",
"tables": {
"guild_form": {
"name": "guild_form",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"guild_id": {
"name": "guild_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"repository": {
"name": "repository",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"forum_post": {
"name": "forum_post",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"guild_form_guild_id_guild_id_fk": {
"name": "guild_form_guild_id_guild_id_fk",
"tableFrom": "guild_form",
"tableTo": "guild",
"columnsFrom": [
"guild_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"guild": {
"name": "guild",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"webhook": {
"name": "webhook",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"webhook_type": {
"name": "webhook_type",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
Loading

0 comments on commit 1eebe85

Please sign in to comment.