diff --git a/api/drizzle/0021_woozy_inhumans.sql b/api/drizzle/0021_woozy_inhumans.sql new file mode 100644 index 000000000..8f20bd126 --- /dev/null +++ b/api/drizzle/0021_woozy_inhumans.sql @@ -0,0 +1,35 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_ai_request_logs` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `log` text NOT NULL, + `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL +); +--> statement-breakpoint +INSERT INTO `__new_ai_request_logs`("id", "log", "created_at") SELECT "id", "log", "created_at" FROM `ai_request_logs`;--> statement-breakpoint +DROP TABLE `ai_request_logs`;--> statement-breakpoint +ALTER TABLE `__new_ai_request_logs` RENAME TO `ai_request_logs`;--> statement-breakpoint +PRAGMA foreign_keys=ON;--> statement-breakpoint +CREATE TABLE `__new_settings` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `key` text NOT NULL, + `value` text DEFAULT '' NOT NULL, + `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL, + `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL +); +--> statement-breakpoint +INSERT INTO `__new_settings`("id", "key", "value", "created_at", "updated_at") SELECT "id", "key", "value", "created_at", "updated_at" FROM `settings`;--> statement-breakpoint +DROP TABLE `settings`;--> statement-breakpoint +ALTER TABLE `__new_settings` RENAME TO `settings`;--> statement-breakpoint +CREATE UNIQUE INDEX `settings_key_unique` ON `settings` (`key`);--> statement-breakpoint +CREATE TABLE `__new_tokens` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `value` text NOT NULL, + `expires_at` text, + `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL, + `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL +); +--> statement-breakpoint +INSERT INTO `__new_tokens`("id", "value", "expires_at", "created_at", "updated_at") SELECT "id", "value", "expires_at", "created_at", "updated_at" FROM `tokens`;--> statement-breakpoint +DROP TABLE `tokens`;--> statement-breakpoint +ALTER TABLE `__new_tokens` RENAME TO `tokens`;--> statement-breakpoint +CREATE UNIQUE INDEX `tokens_value_unique` ON `tokens` (`value`); \ No newline at end of file diff --git a/api/drizzle/meta/0021_snapshot.json b/api/drizzle/meta/0021_snapshot.json new file mode 100644 index 000000000..e359cf271 --- /dev/null +++ b/api/drizzle/meta/0021_snapshot.json @@ -0,0 +1,469 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "5b33c482-c557-44bc-91db-952b0c954fb3", + "prevId": "e1c6675a-d6eb-4b22-bf65-78d0f199a3ad", + "tables": { + "ai_request_logs": { + "name": "ai_request_logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "log": { + "name": "log", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "app_requests": { + "name": "app_requests", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "request_method": { + "name": "request_method", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_url": { + "name": "request_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_headers": { + "name": "request_headers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_query_params": { + "name": "request_query_params", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_path_params": { + "name": "request_path_params", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_body": { + "name": "request_body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_route": { + "name": "request_route", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "app_responses": { + "name": "app_responses", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "response_status_code": { + "name": "response_status_code", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_time": { + "name": "response_time", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_headers": { + "name": "response_headers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_body": { + "name": "response_body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failure_details": { + "name": "failure_details", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_failure": { + "name": "is_failure", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + }, + "request_id": { + "name": "request_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "app_responses_request_id_app_requests_id_fk": { + "name": "app_responses_request_id_app_requests_id_fk", + "tableFrom": "app_responses", + "tableTo": "app_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "app_routes": { + "name": "app_routes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "handler": { + "name": "handler", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "handler_type": { + "name": "handler_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "currentlyRegistered": { + "name": "currentlyRegistered", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "registration_order": { + "name": "registration_order", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": -1 + }, + "route_origin": { + "name": "route_origin", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'discovered'" + }, + "openapi_spec": { + "name": "openapi_spec", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "request_type": { + "name": "request_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'http'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "otel_spans": { + "name": "otel_spans", + "columns": { + "inner": { + "name": "inner", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "span_id": { + "name": "span_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + } + }, + "indexes": { + "settings_key_unique": { + "name": "settings_key_unique", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tokens": { + "name": "tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))" + } + }, + "indexes": { + "tokens_value_unique": { + "name": "tokens_value_unique", + "columns": [ + "value" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/api/drizzle/meta/_journal.json b/api/drizzle/meta/_journal.json index bd8877fce..7e0406ffe 100644 --- a/api/drizzle/meta/_journal.json +++ b/api/drizzle/meta/_journal.json @@ -148,6 +148,13 @@ "when": 1733842457960, "tag": "0020_misty_siren", "breakpoints": true + }, + { + "idx": 21, + "version": "6", + "when": 1733842554772, + "tag": "0021_woozy_inhumans", + "breakpoints": true } ] } \ No newline at end of file diff --git a/api/src/db/schema.ts b/api/src/db/schema.ts index 1e423459f..fc0a3fc71 100644 --- a/api/src/db/schema.ts +++ b/api/src/db/schema.ts @@ -148,8 +148,12 @@ export const settings = sqliteTable("settings", { id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }), key: text("key").notNull().unique(), value: text("value").notNull().default(""), - createdAt: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`), - updatedAt: text("updated_at").notNull().default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at") + .notNull() + .default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`), + updatedAt: text("updated_at") + .notNull() + .default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`), }); export type Setting = typeof settings.$inferSelect; @@ -160,8 +164,12 @@ export const tokens = sqliteTable("tokens", { id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }), value: text("value").notNull().unique(), expiresAt: text("expires_at"), - createdAt: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`), - updatedAt: text("updated_at").notNull().default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at") + .notNull() + .default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`), + updatedAt: text("updated_at") + .notNull() + .default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`), }); export type Token = typeof tokens.$inferSelect; @@ -171,5 +179,7 @@ export type NewToken = typeof tokens.$inferInsert; export const aiRequestLogs = sqliteTable("ai_request_logs", { id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }), log: text("log", { mode: "json" }).notNull(), - createdAt: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at") + .notNull() + .default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`), });