-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: init drizzle * feat: add schema and drizzle boilerplate * feat: add message template helpers * fix: pluralize table name * feat: add user helpers, move to helpers folder * feat: add template deletion helper * feat: add user helper * fix: return insert values and parity --------- Co-authored-by: Jasper Mayone <[email protected]>
- Loading branch information
1 parent
d32c521
commit c348d1e
Showing
16 changed files
with
1,591 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "dotenv/config"; | ||
import type { Config } from "drizzle-kit"; | ||
|
||
export default { | ||
schema: "./src/db/schema.ts", | ||
out: "./migrations", | ||
driver: "pg", | ||
dbCredentials: { | ||
connectionString: 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,15 @@ | ||
CREATE TABLE IF NOT EXISTS "bloom_templates" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"name" text NOT NULL, | ||
"content" text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "bloom_user" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"external_id" text NOT NULL, | ||
"initial_message_content" text NOT NULL, | ||
"initial_message_timestamp" timestamp (3) DEFAULT now() NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX IF NOT EXISTS "templates_name_idx" ON "bloom_templates" ("name");--> statement-breakpoint | ||
CREATE UNIQUE INDEX IF NOT EXISTS "user_external_id_idx" ON "bloom_user" ("external_id"); |
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 @@ | ||
ALTER TABLE "bloom_user" RENAME TO "bloom_users"; |
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,94 @@ | ||
{ | ||
"id": "3dc8027f-a4c1-42ce-bf89-fcc36761156e", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"version": "5", | ||
"dialect": "pg", | ||
"tables": { | ||
"bloom_templates": { | ||
"name": "bloom_templates", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "serial", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"name": { | ||
"name": "name", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"content": { | ||
"name": "content", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": { | ||
"templates_name_idx": { | ||
"name": "templates_name_idx", | ||
"columns": [ | ||
"name" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"bloom_user": { | ||
"name": "bloom_user", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "serial", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"external_id": { | ||
"name": "external_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"initial_message_content": { | ||
"name": "initial_message_content", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"initial_message_timestamp": { | ||
"name": "initial_message_timestamp", | ||
"type": "timestamp (3)", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": "now()" | ||
} | ||
}, | ||
"indexes": { | ||
"user_external_id_idx": { | ||
"name": "user_external_id_idx", | ||
"columns": [ | ||
"external_id" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": {}, | ||
"schemas": {}, | ||
"_meta": { | ||
"columns": {}, | ||
"schemas": {}, | ||
"tables": {} | ||
} | ||
} |
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,94 @@ | ||
{ | ||
"id": "40225452-e629-4653-bb6b-16ac90b546a6", | ||
"prevId": "3dc8027f-a4c1-42ce-bf89-fcc36761156e", | ||
"version": "5", | ||
"dialect": "pg", | ||
"tables": { | ||
"bloom_templates": { | ||
"name": "bloom_templates", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "serial", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"name": { | ||
"name": "name", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"content": { | ||
"name": "content", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": { | ||
"templates_name_idx": { | ||
"name": "templates_name_idx", | ||
"columns": [ | ||
"name" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"bloom_users": { | ||
"name": "bloom_users", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "serial", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"external_id": { | ||
"name": "external_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"initial_message_content": { | ||
"name": "initial_message_content", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"initial_message_timestamp": { | ||
"name": "initial_message_timestamp", | ||
"type": "timestamp (3)", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": "now()" | ||
} | ||
}, | ||
"indexes": { | ||
"user_external_id_idx": { | ||
"name": "user_external_id_idx", | ||
"columns": [ | ||
"external_id" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": {}, | ||
"schemas": {}, | ||
"_meta": { | ||
"columns": {}, | ||
"schemas": {}, | ||
"tables": {} | ||
} | ||
} |
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,20 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "pg", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "5", | ||
"when": 1715221164313, | ||
"tag": "0000_yellow_stardust", | ||
"breakpoints": true | ||
}, | ||
{ | ||
"idx": 1, | ||
"version": "5", | ||
"when": 1715222353526, | ||
"tag": "0001_closed_pixie", | ||
"breakpoints": true | ||
} | ||
] | ||
} |
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 |
---|---|---|
|
@@ -13,7 +13,9 @@ | |
"scripts": { | ||
"start": "node dist/index.js", | ||
"build": "tsc", | ||
"dev": "nodemon src/index.ts" | ||
"dev": "nodemon src/index.ts", | ||
"db:migrate": "tsx scripts/migrate.ts", | ||
"db:gen-migration": "drizzle-kit generate:pg" | ||
}, | ||
"keywords": [], | ||
"author": "Jasper Mayone <[email protected]>", | ||
|
@@ -28,11 +30,15 @@ | |
"@types/express": "^4.17.21", | ||
"colors": "^1.4.0", | ||
"dotenv": "^16.4.5", | ||
"drizzle-orm": "^0.30.10", | ||
"express": "^4.19.2", | ||
"js-yaml": "^4.1.0", | ||
"nodemon": "^3.0.3" | ||
"nodemon": "^3.0.3", | ||
"postgres": "^3.4.4", | ||
"tsx": "^4.9.3" | ||
}, | ||
"devDependencies": { | ||
"drizzle-kit": "^0.20.18", | ||
"prisma": "^5.13.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "~5.4.3" | ||
|
Oops, something went wrong.