From 80187500ea1b146d1eb363546878bf6651007b5d Mon Sep 17 00:00:00 2001 From: beo3000 Date: Fri, 20 Feb 2026 20:16:50 +0100 Subject: [PATCH] deploy1 --- ka-note/deploy.ps1 | 24 + .../server/drizzle/0001_sweet_mister_fear.sql | 1 + .../server/drizzle/meta/0001_snapshot.json | 449 ++++++++++++++++++ ka-note/server/drizzle/meta/_journal.json | 7 + ka-note/server/src/db/connection.ts | 4 + 5 files changed, 485 insertions(+) create mode 100644 ka-note/deploy.ps1 create mode 100644 ka-note/server/drizzle/0001_sweet_mister_fear.sql create mode 100644 ka-note/server/drizzle/meta/0001_snapshot.json diff --git a/ka-note/deploy.ps1 b/ka-note/deploy.ps1 new file mode 100644 index 0000000..b02a192 --- /dev/null +++ b/ka-note/deploy.ps1 @@ -0,0 +1,24 @@ +$ErrorActionPreference = "Stop" + +$ACR = "koogleacr" +$APP = "ka-note" +$RG = "rg-koogle-prod" +$IMAGE = "$ACR.azurecr.io/${APP}:latest" + +Write-Host "=== Generate migrations ===" -ForegroundColor Cyan +npx drizzle-kit generate --config server/drizzle.config.ts +if ($LASTEXITCODE -ne 0) { throw "Migration generation failed" } + +Write-Host "=== Build Docker image ===" -ForegroundColor Cyan +docker build -t $IMAGE . +if ($LASTEXITCODE -ne 0) { throw "Docker build failed" } + +Write-Host "=== Push to ACR ===" -ForegroundColor Cyan +docker push $IMAGE +if ($LASTEXITCODE -ne 0) { throw "Docker push failed" } + +Write-Host "=== Restart App Service ===" -ForegroundColor Cyan +az webapp restart --name $APP --resource-group $RG + +Write-Host "=== Done! ===" -ForegroundColor Green +Write-Host "Check: https://$APP.azurewebsites.net" diff --git a/ka-note/server/drizzle/0001_sweet_mister_fear.sql b/ka-note/server/drizzle/0001_sweet_mister_fear.sql new file mode 100644 index 0000000..da2c06d --- /dev/null +++ b/ka-note/server/drizzle/0001_sweet_mister_fear.sql @@ -0,0 +1 @@ +ALTER TABLE `contexts` ADD `is_favorite` integer DEFAULT false NOT NULL; \ No newline at end of file diff --git a/ka-note/server/drizzle/meta/0001_snapshot.json b/ka-note/server/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..a8eda2e --- /dev/null +++ b/ka-note/server/drizzle/meta/0001_snapshot.json @@ -0,0 +1,449 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "d34a5cba-aa78-42d5-99ea-2f4b986e167b", + "prevId": "c350243b-2319-4387-8ed6-5ebb0c7a6814", + "tables": { + "contexts": { + "name": "contexts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "meta": { + "name": "meta", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_favorite": { + "name": "is_favorite", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + } + }, + "indexes": { + "contexts_updated_at_idx": { + "name": "contexts_updated_at_idx", + "columns": [ + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "history_entries": { + "name": "history_entries", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "topic_id": { + "name": "topic_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "linked_context_id": { + "name": "linked_context_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "done_at": { + "name": "done_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + } + }, + "indexes": { + "history_entries_updated_at_idx": { + "name": "history_entries_updated_at_idx", + "columns": [ + "updated_at" + ], + "isUnique": false + }, + "history_entries_topic_id_idx": { + "name": "history_entries_topic_id_idx", + "columns": [ + "topic_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "history_entries_topic_id_topics_id_fk": { + "name": "history_entries_topic_id_topics_id_fk", + "tableFrom": "history_entries", + "tableTo": "topics", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ratings": { + "name": "ratings", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "topic_id": { + "name": "topic_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "history_entry_id": { + "name": "history_entry_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "person_name": { + "name": "person_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + } + }, + "indexes": { + "ratings_updated_at_idx": { + "name": "ratings_updated_at_idx", + "columns": [ + "updated_at" + ], + "isUnique": false + }, + "ratings_topic_id_idx": { + "name": "ratings_topic_id_idx", + "columns": [ + "topic_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ratings_topic_id_topics_id_fk": { + "name": "ratings_topic_id_topics_id_fk", + "tableFrom": "ratings", + "tableTo": "topics", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "ratings_history_entry_id_history_entries_id_fk": { + "name": "ratings_history_entry_id_history_entries_id_fk", + "tableFrom": "ratings", + "tableTo": "history_entries", + "columnsFrom": [ + "history_entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "topics": { + "name": "topics", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "snooze_until": { + "name": "snooze_until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "is_new": { + "name": "is_new", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + } + }, + "indexes": { + "topics_updated_at_idx": { + "name": "topics_updated_at_idx", + "columns": [ + "updated_at" + ], + "isUnique": false + }, + "topics_context_id_idx": { + "name": "topics_context_id_idx", + "columns": [ + "context_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "topics_context_id_contexts_id_fk": { + "name": "topics_context_id_contexts_id_fk", + "tableFrom": "topics", + "tableTo": "contexts", + "columnsFrom": [ + "context_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/ka-note/server/drizzle/meta/_journal.json b/ka-note/server/drizzle/meta/_journal.json index bf689f4..84984c0 100644 --- a/ka-note/server/drizzle/meta/_journal.json +++ b/ka-note/server/drizzle/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1771593711032, "tag": "0000_lying_ben_urich", "breakpoints": true + }, + { + "idx": 1, + "version": "6", + "when": 1771614736457, + "tag": "0001_sweet_mister_fear", + "breakpoints": true } ] } \ No newline at end of file diff --git a/ka-note/server/src/db/connection.ts b/ka-note/server/src/db/connection.ts index def9966..1998e13 100644 --- a/ka-note/server/src/db/connection.ts +++ b/ka-note/server/src/db/connection.ts @@ -3,12 +3,16 @@ import { drizzle } from 'drizzle-orm/libsql'; import { migrate } from 'drizzle-orm/libsql/migrator'; import * as schema from './schema.js'; import path from 'node:path'; +import fs from 'node:fs'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const dbPath = process.env.DATABASE_PATH || './ka-note.db'; +// Ensure parent directory exists +fs.mkdirSync(path.dirname(dbPath), { recursive: true }); + const client = createClient({ url: `file:${dbPath}`, });