From c647cbdc6cacdb9fce1bb6c581d9b7e7b0fc4802 Mon Sep 17 00:00:00 2001 From: vibsin9322 Date: Tue, 19 Aug 2025 14:14:30 +0900 Subject: [PATCH] Fix database schema compatibility - remove invalid fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove id, created_at, updated_at from client-side fileData - Extract only valid database fields in addFile and updateFile functions - Let database handle UUID generation and timestamps automatically - Clean separation between client data structure and database schema - Fix persistent createdAt column error by filtering client-side fields This should resolve: "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 | 13 ++++++------- supabase-config.js | 29 +++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/script.js b/script.js index 7164e93..04e901d 100644 --- a/script.js +++ b/script.js @@ -433,11 +433,12 @@ class FileManager { // localStorage ํด๋ฐฑ ๋ฉ”์„œ๋“œ๋“ค addFileLocally(fileData) { - // ๋กœ์ปฌ ์ €์žฅ์‹œ์—๋„ ์˜ฌ๋ฐ”๋ฅธ ์ปฌ๋Ÿผ๋ช… ์‚ฌ์šฉ + // ๋กœ์ปฌ ์ €์žฅ์šฉ ๋ฐ์ดํ„ฐ ์ƒ์„ฑ (ID์™€ ํƒ€์ž„์Šคํƒฌํ”„ ์ถ”๊ฐ€) const localFileData = { + id: this.generateId(), ...fileData, - created_at: fileData.created_at || new Date().toISOString(), - updated_at: fileData.updated_at || new Date().toISOString() + created_at: new Date().toISOString(), + updated_at: new Date().toISOString() }; this.files.push(localFileData); @@ -445,6 +446,7 @@ class FileManager { this.renderFiles(); this.updateEmptyState(); this.showNotification('์ƒˆ ์ž๋ฃŒ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค! (๋กœ์ปฌ ์ €์žฅ)', 'success'); + this.clearForm(); // ํผ ์ดˆ๊ธฐํ™” } updateFileLocally(id, updates) { @@ -635,14 +637,11 @@ class FileManager { } const fileData = { - id: this.generateId(), title, description, category, tags, - files: [], - created_at: new Date().toISOString(), - updated_at: new Date().toISOString() + files: [] // ์ฒจ๋ถ€ํŒŒ์ผ ์ž„์‹œ ์ €์žฅ์šฉ (Supabase ์ „์†ก์‹œ ์ œ์™ธ๋จ) }; if (fileInput.files.length > 0) { diff --git a/supabase-config.js b/supabase-config.js index 5fb5000..a1058cf 100644 --- a/supabase-config.js +++ b/supabase-config.js @@ -122,12 +122,19 @@ const SupabaseHelper = { async addFile(fileData, userId) { if (!supabase) throw new Error('Supabase๊ฐ€ ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.'); + // ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์Šคํ‚ค๋งˆ์— ๋งž๋Š” ํ•„๋“œ๋งŒ ์ถ”์ถœ + const dbFileData = { + title: fileData.title, + description: fileData.description || '', + category: fileData.category, + tags: fileData.tags || [], + user_id: userId + // created_at, updated_at์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ์ž๋™ ์ƒ์„ฑ + }; + const { data, error } = await supabase .from('files') - .insert([{ - ...fileData, - user_id: userId - }]) + .insert([dbFileData]) .select() .single(); @@ -139,12 +146,18 @@ const SupabaseHelper = { async updateFile(id, updates, userId) { if (!supabase) throw new Error('Supabase๊ฐ€ ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.'); + // ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์Šคํ‚ค๋งˆ์— ๋งž๋Š” ํ•„๋“œ๋งŒ ์ถ”์ถœ + const dbUpdates = { + title: updates.title, + description: updates.description, + category: updates.category, + tags: updates.tags || [] + // updated_at์€ ํŠธ๋ฆฌ๊ฑฐ์— ์˜ํ•ด ์ž๋™ ์—…๋ฐ์ดํŠธ๋จ + }; + const { data, error } = await supabase .from('files') - .update({ - ...updates, - updated_at: new Date().toISOString() - }) + .update(dbUpdates) .eq('id', id) .eq('user_id', userId) .select()