Try drizzle
This commit is contained in:
parent
17bfd0cac1
commit
c332a1b6f1
10 changed files with 107 additions and 47 deletions
|
|
@ -4,6 +4,7 @@ import * as dotenv from "dotenv";
|
|||
|
||||
dotenv.config();
|
||||
|
||||
// @ts-ignore
|
||||
migrate(db, {
|
||||
migrationsFolder: "lib/db/migrations",
|
||||
})
|
||||
|
|
|
|||
1
lib/db/migrations/0002_striped_purifiers.sql
Normal file
1
lib/db/migrations/0002_striped_purifiers.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE "chats" ADD COLUMN "messages" json DEFAULT '{}'::json NOT NULL;
|
||||
49
lib/db/migrations/meta/0002_snapshot.json
Normal file
49
lib/db/migrations/meta/0002_snapshot.json
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"version": "5",
|
||||
"dialect": "pg",
|
||||
"id": "e3f4035a-a940-4529-b037-1737e178d88b",
|
||||
"prevId": "e8eef642-fc25-4737-8e75-5ad1e8c53b84",
|
||||
"tables": {
|
||||
"chats": {
|
||||
"name": "chats",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"userId": {
|
||||
"name": "userId",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"messages": {
|
||||
"name": "messages",
|
||||
"type": "json",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'{}'::json"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,13 @@
|
|||
"when": 1685719963202,
|
||||
"tag": "0001_naive_gunslinger",
|
||||
"breakpoints": false
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "5",
|
||||
"when": 1685720130302,
|
||||
"tag": "0002_striped_purifiers",
|
||||
"breakpoints": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { sql } from "@vercel/postgres";
|
||||
import { pgTable, text } from "drizzle-orm/pg-core";
|
||||
import { json, pgTable, text } from "drizzle-orm/pg-core";
|
||||
import { drizzle } from "drizzle-orm/vercel-postgres";
|
||||
|
||||
// const connection = createPool({ connectionString: process.env.POSTGRES_URL });
|
||||
|
|
@ -8,7 +8,7 @@ export const chats = pgTable("chats", {
|
|||
id: text("id").notNull().primaryKey(),
|
||||
title: text("role").notNull(),
|
||||
userId: text("userId").notNull(),
|
||||
// messages: json("messages").notNull().default({}),
|
||||
messages: json("messages").notNull().default({}),
|
||||
// .references(() => users.id),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue