This commit is contained in:
beo3000 2026-02-20 20:16:50 +01:00
parent 9886b602f0
commit 80187500ea
5 changed files with 485 additions and 0 deletions

24
ka-note/deploy.ps1 Normal file
View File

@ -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"

View File

@ -0,0 +1 @@
ALTER TABLE `contexts` ADD `is_favorite` integer DEFAULT false NOT NULL;

View File

@ -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": {}
}
}

View File

@ -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
}
]
}

View File

@ -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}`,
});