hskLog 테이블의 actionBy 필드의 Foreign key constraint이 잘못 지정되어 있던 버그 수정

This commit is contained in:
static
2025-01-19 02:03:44 +09:00
parent 6018b03523
commit 0002b4e5f2
8 changed files with 33 additions and 2634 deletions

View File

@@ -59,7 +59,10 @@ CREATE TABLE `file` (
`content_hmac` text, `content_hmac` text,
`content_type` text NOT NULL, `content_type` text NOT NULL,
`encrypted_content_iv` text NOT NULL, `encrypted_content_iv` text NOT NULL,
`encrypted_content_hash` text NOT NULL,
`encrypted_name` text NOT NULL, `encrypted_name` text NOT NULL,
`encrypted_created_at` text,
`encrypted_last_modified_at` text NOT NULL,
FOREIGN KEY (`parent_id`) REFERENCES `directory`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`parent_id`) REFERENCES `directory`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`user_id`,`master_encryption_key_version`) REFERENCES `master_encryption_key`(`user_id`,`version`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`user_id`,`master_encryption_key_version`) REFERENCES `master_encryption_key`(`user_id`,`version`) ON UPDATE no action ON DELETE no action,
@@ -94,7 +97,7 @@ CREATE TABLE `hmac_secret_key_log` (
`action` text NOT NULL, `action` text NOT NULL,
`action_by` integer, `action_by` integer,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`action_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`action_by`) REFERENCES `client`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`user_id`,`hmac_secret_key_version`) REFERENCES `hmac_secret_key`(`user_id`,`version`) ON UPDATE no action ON DELETE no action FOREIGN KEY (`user_id`,`hmac_secret_key_version`) REFERENCES `hmac_secret_key`(`user_id`,`version`) ON UPDATE no action ON DELETE no action
); );
--> statement-breakpoint --> statement-breakpoint

View File

@@ -1,2 +0,0 @@
ALTER TABLE `file` ADD `encrypted_created_at` text;--> statement-breakpoint
ALTER TABLE `file` ADD `encrypted_last_modified_at` text NOT NULL;

View File

@@ -1 +0,0 @@
ALTER TABLE `file` ADD `encrypted_content_hash` text NOT NULL;

View File

@@ -1,7 +1,7 @@
{ {
"version": "6", "version": "6",
"dialect": "sqlite", "dialect": "sqlite",
"id": "928e5669-81cf-486c-9122-8ee64fc9f457", "id": "396a26d6-6f55-4162-a23e-c1117f3a3757",
"prevId": "00000000-0000-0000-0000-000000000000", "prevId": "00000000-0000-0000-0000-000000000000",
"tables": { "tables": {
"client": { "client": {
@@ -470,12 +470,33 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"encrypted_content_hash": {
"name": "encrypted_content_hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"encrypted_name": { "encrypted_name": {
"name": "encrypted_name", "name": "encrypted_name",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
},
"encrypted_created_at": {
"name": "encrypted_created_at",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"encrypted_last_modified_at": {
"name": "encrypted_last_modified_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
} }
}, },
"indexes": { "indexes": {
@@ -763,10 +784,10 @@
"onDelete": "no action", "onDelete": "no action",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"hmac_secret_key_log_action_by_user_id_fk": { "hmac_secret_key_log_action_by_client_id_fk": {
"name": "hmac_secret_key_log_action_by_user_id_fk", "name": "hmac_secret_key_log_action_by_client_id_fk",
"tableFrom": "hmac_secret_key_log", "tableFrom": "hmac_secret_key_log",
"tableTo": "user", "tableTo": "client",
"columnsFrom": [ "columnsFrom": [
"action_by" "action_by"
], ],

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -5,22 +5,8 @@
{ {
"idx": 0, "idx": 0,
"version": "6", "version": "6",
"when": 1736704436996, "when": 1737219722656,
"tag": "0000_unknown_stark_industries", "tag": "0000_regular_the_watchers",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1736720831242,
"tag": "0001_blushing_alice",
"breakpoints": true
},
{
"idx": 2,
"version": "6",
"when": 1737191517463,
"tag": "0002_good_talisman",
"breakpoints": true "breakpoints": true
} }
] ]

View File

@@ -1,4 +1,5 @@
import { sqliteTable, text, integer, primaryKey, foreignKey } from "drizzle-orm/sqlite-core"; import { sqliteTable, text, integer, primaryKey, foreignKey } from "drizzle-orm/sqlite-core";
import { client } from "./client";
import { mek } from "./mek"; import { mek } from "./mek";
import { user } from "./user"; import { user } from "./user";
@@ -32,7 +33,7 @@ export const hskLog = sqliteTable(
hskVersion: integer("hmac_secret_key_version").notNull(), hskVersion: integer("hmac_secret_key_version").notNull(),
timestamp: integer("timestamp", { mode: "timestamp_ms" }).notNull(), timestamp: integer("timestamp", { mode: "timestamp_ms" }).notNull(),
action: text("action", { enum: ["create"] }).notNull(), action: text("action", { enum: ["create"] }).notNull(),
actionBy: integer("action_by").references(() => user.id), actionBy: integer("action_by").references(() => client.id),
}, },
(t) => ({ (t) => ({
ref: foreignKey({ ref: foreignKey({