feat: getting the db ready
This commit is contained in:
7
server/db/index.ts
Normal file
7
server/db/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import Database from 'better-sqlite3'
|
||||
import { drizzle } from 'drizzle-orm/better-sqlite3'
|
||||
import * as schema from './schema'
|
||||
import { env } from '../env'
|
||||
|
||||
const sqlite = new Database(env.DATABASE_URL)
|
||||
export const db = drizzle(sqlite, { schema })
|
||||
10
server/db/migrations/0000_pretty_mentor.sql
Normal file
10
server/db/migrations/0000_pretty_mentor.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE `links` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`path` text NOT NULL,
|
||||
`url` text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `links_name_unique` ON `links` (`name`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `links_path_unique` ON `links` (`path`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `links_url_unique` ON `links` (`url`);
|
||||
78
server/db/migrations/meta/0000_snapshot.json
Normal file
78
server/db/migrations/meta/0000_snapshot.json
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"id": "d03860ad-0d5c-4943-92ba-d704c74e1501",
|
||||
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||
"tables": {
|
||||
"links": {
|
||||
"name": "links",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "integer",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"path": {
|
||||
"name": "path",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"url": {
|
||||
"name": "url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"links_name_unique": {
|
||||
"name": "links_name_unique",
|
||||
"columns": [
|
||||
"name"
|
||||
],
|
||||
"isUnique": true
|
||||
},
|
||||
"links_path_unique": {
|
||||
"name": "links_path_unique",
|
||||
"columns": [
|
||||
"path"
|
||||
],
|
||||
"isUnique": true
|
||||
},
|
||||
"links_url_unique": {
|
||||
"name": "links_url_unique",
|
||||
"columns": [
|
||||
"url"
|
||||
],
|
||||
"isUnique": true
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
}
|
||||
},
|
||||
"views": {},
|
||||
"enums": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
},
|
||||
"internal": {
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
13
server/db/migrations/meta/_journal.json
Normal file
13
server/db/migrations/meta/_journal.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "sqlite",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "6",
|
||||
"when": 1773788954273,
|
||||
"tag": "0000_pretty_mentor",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
8
server/db/schema.ts
Normal file
8
server/db/schema.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const links = sqliteTable("links", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
name: text("name").notNull().unique(),
|
||||
path: text("path").notNull().unique(),
|
||||
url: text("url").notNull().unique(),
|
||||
});
|
||||
Reference in New Issue
Block a user