データベースで「shaders」→「scenes」に名変更
守矢諏訪子 <suwako@076.moe>、2026-06-28 18:39
コミット c35ce3348c94d51c6abd1f10f2edc8caa500ecfa
・親 997e030
・ファイルを見る
2個のファイル、+22 -22
| @@ -86,7 +86,7 @@ | ||
| 86 | 86 | WHERE id = NEW.id; |
| 87 | 87 | END; |
| 88 | 88 | |
| 89 | -CREATE TABLE IF NOT EXISTS shaders ( | |
| 89 | +CREATE TABLE IF NOT EXISTS scenes ( | |
| 90 | 90 | id INTEGER PRIMARY KEY, |
| 91 | 91 | name TEXT UNIQUE NOT NULL, |
| 92 | 92 | description TEXT, |
| @@ -94,32 +94,32 @@ | ||
| 94 | 94 | updated_at DATETIME DEFAULT CURRENT_TIMESTAMP |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | -CREATE UNIQUE INDEX IF NOT EXISTS idx_shaders_name ON shaders(name); | |
| 97 | +CREATE UNIQUE INDEX IF NOT EXISTS idx_scenes_name ON scenes(name); | |
| 98 | 98 | |
| 99 | -CREATE TRIGGER IF NOT EXISTS shaders_updated_at | |
| 100 | -AFTER UPDATE ON shaders | |
| 99 | +CREATE TRIGGER IF NOT EXISTS scenes_updated_at | |
| 100 | +AFTER UPDATE ON scenes | |
| 101 | 101 | BEGIN |
| 102 | - UPDATE shaders | |
| 102 | + UPDATE scenes | |
| 103 | 103 | SET updated_at = CURRENT_TIMESTAMP |
| 104 | 104 | WHERE id = NEW.id; |
| 105 | 105 | END; |
| 106 | 106 | |
| 107 | -CREATE TABLE IF NOT EXISTS shader_code ( | |
| 107 | +CREATE TABLE IF NOT EXISTS scene_code ( | |
| 108 | 108 | id INTEGER PRIMARY KEY, |
| 109 | - shader_id INTEGER NOT NULL, | |
| 109 | + scene_id INTEGER NOT NULL, | |
| 110 | 110 | code_type INTEGER NOT NULL, |
| 111 | 111 | code TEXT NOT NULL, |
| 112 | 112 | filename TEXT, |
| 113 | 113 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
| 114 | 114 | updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
| 115 | 115 | |
| 116 | - FOREIGN KEY (shader_id) REFERENCES shaders(id) ON DELETE CASCADE | |
| 116 | + FOREIGN KEY (scene_id) REFERENCES scenes(id) ON DELETE CASCADE | |
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | -CREATE TRIGGER IF NOT EXISTS shader_code_updated_at | |
| 120 | -AFTER UPDATE ON shader_code | |
| 119 | +CREATE TRIGGER IF NOT EXISTS scene_code_updated_at | |
| 120 | +AFTER UPDATE ON scene_code | |
| 121 | 121 | BEGIN |
| 122 | - UPDATE shader_code | |
| 122 | + UPDATE scene_code | |
| 123 | 123 | SET updated_at = CURRENT_TIMESTAMP |
| 124 | 124 | WHERE id = NEW.id; |
| 125 | 125 | END; |
| @@ -272,7 +272,7 @@ | ||
| 272 | 272 | |
| 273 | 273 | { |
| 274 | 274 | sqlitepp::Stmt stmt(db.GetDB()); |
| 275 | - stmt.Prepare("INSERT INTO shaders (name, description) VALUES (?, ?);"); | |
| 275 | + stmt.Prepare("INSERT INTO scenes (name, description) VALUES (?, ?);"); | |
| 276 | 276 | stmt.BindText(1, "default"); |
| 277 | 277 | stmt.BindText(2, ""); |
| 278 | 278 | assert(stmt.Step() == SQLITE_DONE && "最初のシェーダーを入れ込みに失敗。\n"); |
| @@ -281,7 +281,7 @@ | ||
| 281 | 281 | |
| 282 | 282 | { |
| 283 | 283 | sqlitepp::Stmt stmt(db.GetDB()); |
| 284 | - stmt.Prepare("INSERT INTO shader_code (shader_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 284 | + stmt.Prepare("INSERT INTO scene_code (scene_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 285 | 285 | stmt.BindInt(1, shaderId); |
| 286 | 286 | stmt.BindInt(2, static_cast<int>(db::ShaderCodeType::GlslVertex)); |
| 287 | 287 | stmt.BindText(3, GetDefaultVertexShader()); |
| @@ -292,7 +292,7 @@ | ||
| 292 | 292 | |
| 293 | 293 | { |
| 294 | 294 | sqlitepp::Stmt stmt(db.GetDB()); |
| 295 | - stmt.Prepare("INSERT INTO shader_code (shader_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 295 | + stmt.Prepare("INSERT INTO scene_code (scene_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 296 | 296 | stmt.BindInt(1, shaderId); |
| 297 | 297 | stmt.BindInt(2, static_cast<int>(db::ShaderCodeType::GlslFragment)); |
| 298 | 298 | stmt.BindText(3, GetDefaultFragmentShader()); |
| @@ -303,7 +303,7 @@ | ||
| 303 | 303 | |
| 304 | 304 | { |
| 305 | 305 | sqlitepp::Stmt stmt(db.GetDB()); |
| 306 | - stmt.Prepare("INSERT INTO shader_code (shader_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 306 | + stmt.Prepare("INSERT INTO scene_code (scene_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 307 | 307 | stmt.BindInt(1, shaderId); |
| 308 | 308 | stmt.BindInt(2, static_cast<int>(db::ShaderCodeType::Lua)); |
| 309 | 309 | stmt.BindText(3, GetDefaultLuaCode()); |
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | namespace db { |
| 44 | 44 | void getShaderCode(sqlitepp::Instance &db, ShaderData &data) { |
| 45 | 45 | sqlitepp::Stmt stmt(db.GetDB()); |
| 46 | - stmt.Prepare("SELECT id, code_type, code, filename FROM shader_code WHERE shader_id = ?;"); | |
| 46 | + stmt.Prepare("SELECT id, code_type, code, filename FROM scene_code WHERE scene_id = ?;"); | |
| 47 | 47 | stmt.BindInt(1, data.id); |
| 48 | 48 | |
| 49 | 49 | while (stmt.Step() == SQLITE_ROW) { |
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | vector<ShaderData> out; |
| 78 | 78 | |
| 79 | 79 | sqlitepp::Stmt stmt(db.GetDB()); |
| 80 | - stmt.Prepare("SELECT id, name, description FROM shaders ORDER BY updated_at DESC;"); | |
| 80 | + stmt.Prepare("SELECT id, name, description FROM scenes ORDER BY updated_at DESC;"); | |
| 81 | 81 | |
| 82 | 82 | while (stmt.Step() == SQLITE_ROW) { |
| 83 | 83 | ShaderData data; |
| @@ -95,7 +95,7 @@ | ||
| 95 | 95 | ShaderData GetShader(sqlitepp::Instance &db, u32 id) { |
| 96 | 96 | ShaderData data = {}; |
| 97 | 97 | sqlitepp::Stmt stmt(db.GetDB()); |
| 98 | - stmt.Prepare("SELECT id, name, description FROM shaders WHERE id = ?;"); | |
| 98 | + stmt.Prepare("SELECT id, name, description FROM scenes WHERE id = ?;"); | |
| 99 | 99 | stmt.BindInt(1, id); |
| 100 | 100 | |
| 101 | 101 | while (stmt.Step() == SQLITE_ROW) { |
| @@ -110,7 +110,7 @@ | ||
| 110 | 110 | |
| 111 | 111 | void insertShaderCode(sqlitepp::Instance &db, const CodeData &data, u32 id) { |
| 112 | 112 | sqlitepp::Stmt stmt(db.GetDB()); |
| 113 | - stmt.Prepare("INSERT INTO shader_code (shader_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 113 | + stmt.Prepare("INSERT INTO scene_code (scene_id, code_type, code, filename) VALUES (?, ?, ?, ?);"); | |
| 114 | 114 | stmt.BindInt(1, id); |
| 115 | 115 | stmt.BindInt(2, static_cast<u32>(data.type)); |
| 116 | 116 | stmt.BindText(3, data.code); |
| @@ -120,7 +120,7 @@ | ||
| 120 | 120 | |
| 121 | 121 | void SaveNewShader(sqlitepp::Instance &db, const ShaderData &data) { |
| 122 | 122 | sqlitepp::Stmt stmt(db.GetDB()); |
| 123 | - stmt.Prepare("INSERT INTO shaders (name, description) VALUES (?, ?);"); | |
| 123 | + stmt.Prepare("INSERT INTO scenes (name, description) VALUES (?, ?);"); | |
| 124 | 124 | |
| 125 | 125 | stmt.BindText(1, data.name); |
| 126 | 126 | stmt.BindText(2, data.description); |
| @@ -134,7 +134,7 @@ | ||
| 134 | 134 | |
| 135 | 135 | void SaveCode(sqlitepp::Instance &db, const CodeData &data) { |
| 136 | 136 | sqlitepp::Stmt stmt(db.GetDB()); |
| 137 | - stmt.Prepare("UPDATE shader_code SET code = ?, filename = ? WHERE id = ?;"); | |
| 137 | + stmt.Prepare("UPDATE scene_code SET code = ?, filename = ? WHERE id = ?;"); | |
| 138 | 138 | |
| 139 | 139 | stmt.BindText(1, data.code); |
| 140 | 140 | stmt.BindText(2, data.filename); |
| @@ -145,7 +145,7 @@ | ||
| 145 | 145 | |
| 146 | 146 | u32 GetLastShaderID(sqlitepp::Instance &db) { |
| 147 | 147 | sqlitepp::Stmt stmt(db.GetDB()); |
| 148 | - stmt.Prepare("SELECT MAX(id) FROM shaders;"); | |
| 148 | + stmt.Prepare("SELECT MAX(id) FROM scenes;"); | |
| 149 | 149 | return (stmt.Step() == SQLITE_ROW) ? stmt.ColumnInt(0) : 0; |
| 150 | 150 | } |
| 151 | 151 | } // namespace db |