From 4eb3bf0e342172c6edbab6b30b895c117cbfdc04 Mon Sep 17 00:00:00 2001 From: vibsin9322 Date: Tue, 19 Aug 2025 14:11:28 +0900 Subject: [PATCH] Fix database column naming mismatch (createdAt vs created_at) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change JavaScript code to use snake_case column names (created_at, updated_at) - Add backward compatibility for existing localStorage data - Fix sorting and display functions to use correct column names - Ensure consistent column naming between database schema and JavaScript code This resolves the error: "Could not find the 'createdAt' column of 'files' in the schema cache" ๐Ÿค– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- script.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/script.js b/script.js index 0c82b6e..7164e93 100644 --- a/script.js +++ b/script.js @@ -433,7 +433,14 @@ class FileManager { // localStorage ํด๋ฐฑ ๋ฉ”์„œ๋“œ๋“ค addFileLocally(fileData) { - this.files.push(fileData); + // ๋กœ์ปฌ ์ €์žฅ์‹œ์—๋„ ์˜ฌ๋ฐ”๋ฅธ ์ปฌ๋Ÿผ๋ช… ์‚ฌ์šฉ + const localFileData = { + ...fileData, + created_at: fileData.created_at || new Date().toISOString(), + updated_at: fileData.updated_at || new Date().toISOString() + }; + + this.files.push(localFileData); this.saveFiles(); this.renderFiles(); this.updateEmptyState(); @@ -634,8 +641,8 @@ class FileManager { category, tags, files: [], - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString() + created_at: new Date().toISOString(), + updated_at: new Date().toISOString() }; if (fileInput.files.length > 0) { @@ -721,7 +728,7 @@ class FileManager { break; case 'date': default: - sortedFiles.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)); + sortedFiles.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); break; } @@ -734,8 +741,8 @@ class FileManager { } createFileHTML(file) { - const createdDate = new Date(file.createdAt).toLocaleDateString('ko-KR'); - const updatedDate = new Date(file.updatedAt).toLocaleDateString('ko-KR'); + const createdDate = new Date(file.created_at).toLocaleDateString('ko-KR'); + const updatedDate = new Date(file.updated_at).toLocaleDateString('ko-KR'); const tagsHTML = file.tags.map(tag => `${tag}`).join(''); const filesHTML = file.files.length > 0 ? `
@@ -916,7 +923,7 @@ class FileManager { break; case 'date': default: - sortedFiles.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)); + sortedFiles.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); break; } @@ -985,7 +992,14 @@ class FileManager { loadFiles() { try { const stored = localStorage.getItem('fileManagerData'); - return stored ? JSON.parse(stored) : []; + const files = stored ? JSON.parse(stored) : []; + + // ๊ธฐ์กด localStorage ๋ฐ์ดํ„ฐ์˜ ํ˜ธํ™˜์„ฑ์„ ์œ„ํ•ด ์ปฌ๋Ÿผ๋ช… ๋ณ€ํ™˜ + return files.map(file => ({ + ...file, + created_at: file.created_at || file.createdAt || new Date().toISOString(), + updated_at: file.updated_at || file.updatedAt || new Date().toISOString() + })); } catch (error) { console.error('ํŒŒ์ผ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค:', error); return [];