データベースで「shaders」→「scenes」に名変更

守矢諏訪子 <suwako@076.moe>、2026-06-28 18:39
コミット c35ce3348c94d51c6abd1f10f2edc8caa500ecfa ・親 997e030 ・ファイルを見る

2個のファイル、+22 -22

@@ -86,7 +86,7 @@
8686 WHERE id = NEW.id;
8787 END;
8888
89-CREATE TABLE IF NOT EXISTS shaders (
89+CREATE TABLE IF NOT EXISTS scenes (
9090 id INTEGER PRIMARY KEY,
9191 name TEXT UNIQUE NOT NULL,
9292 description TEXT,
@@ -94,32 +94,32 @@
9494 updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
9595 );
9696
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);
9898
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
101101 BEGIN
102- UPDATE shaders
102+ UPDATE scenes
103103 SET updated_at = CURRENT_TIMESTAMP
104104 WHERE id = NEW.id;
105105 END;
106106
107-CREATE TABLE IF NOT EXISTS shader_code (
107+CREATE TABLE IF NOT EXISTS scene_code (
108108 id INTEGER PRIMARY KEY,
109- shader_id INTEGER NOT NULL,
109+ scene_id INTEGER NOT NULL,
110110 code_type INTEGER NOT NULL,
111111 code TEXT NOT NULL,
112112 filename TEXT,
113113 created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
114114 updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
115115
116- FOREIGN KEY (shader_id) REFERENCES shaders(id) ON DELETE CASCADE
116+ FOREIGN KEY (scene_id) REFERENCES scenes(id) ON DELETE CASCADE
117117 );
118118
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
121121 BEGIN
122- UPDATE shader_code
122+ UPDATE scene_code
123123 SET updated_at = CURRENT_TIMESTAMP
124124 WHERE id = NEW.id;
125125 END;
@@ -272,7 +272,7 @@
272272
273273 {
274274 sqlitepp::Stmt stmt(db.GetDB());
275- stmt.Prepare("INSERT INTO shaders (name, description) VALUES (?, ?);");
275+ stmt.Prepare("INSERT INTO scenes (name, description) VALUES (?, ?);");
276276 stmt.BindText(1, "default");
277277 stmt.BindText(2, "");
278278 assert(stmt.Step() == SQLITE_DONE && "最初のシェーダーを入れ込みに失敗。\n");
@@ -281,7 +281,7 @@
281281
282282 {
283283 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 (?, ?, ?, ?);");
285285 stmt.BindInt(1, shaderId);
286286 stmt.BindInt(2, static_cast<int>(db::ShaderCodeType::GlslVertex));
287287 stmt.BindText(3, GetDefaultVertexShader());
@@ -292,7 +292,7 @@
292292
293293 {
294294 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 (?, ?, ?, ?);");
296296 stmt.BindInt(1, shaderId);
297297 stmt.BindInt(2, static_cast<int>(db::ShaderCodeType::GlslFragment));
298298 stmt.BindText(3, GetDefaultFragmentShader());
@@ -303,7 +303,7 @@
303303
304304 {
305305 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 (?, ?, ?, ?);");
307307 stmt.BindInt(1, shaderId);
308308 stmt.BindInt(2, static_cast<int>(db::ShaderCodeType::Lua));
309309 stmt.BindText(3, GetDefaultLuaCode());
@@ -43,7 +43,7 @@
4343 namespace db {
4444 void getShaderCode(sqlitepp::Instance &db, ShaderData &data) {
4545 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 = ?;");
4747 stmt.BindInt(1, data.id);
4848
4949 while (stmt.Step() == SQLITE_ROW) {
@@ -77,7 +77,7 @@
7777 vector<ShaderData> out;
7878
7979 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;");
8181
8282 while (stmt.Step() == SQLITE_ROW) {
8383 ShaderData data;
@@ -95,7 +95,7 @@
9595 ShaderData GetShader(sqlitepp::Instance &db, u32 id) {
9696 ShaderData data = {};
9797 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 = ?;");
9999 stmt.BindInt(1, id);
100100
101101 while (stmt.Step() == SQLITE_ROW) {
@@ -110,7 +110,7 @@
110110
111111 void insertShaderCode(sqlitepp::Instance &db, const CodeData &data, u32 id) {
112112 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 (?, ?, ?, ?);");
114114 stmt.BindInt(1, id);
115115 stmt.BindInt(2, static_cast<u32>(data.type));
116116 stmt.BindText(3, data.code);
@@ -120,7 +120,7 @@
120120
121121 void SaveNewShader(sqlitepp::Instance &db, const ShaderData &data) {
122122 sqlitepp::Stmt stmt(db.GetDB());
123- stmt.Prepare("INSERT INTO shaders (name, description) VALUES (?, ?);");
123+ stmt.Prepare("INSERT INTO scenes (name, description) VALUES (?, ?);");
124124
125125 stmt.BindText(1, data.name);
126126 stmt.BindText(2, data.description);
@@ -134,7 +134,7 @@
134134
135135 void SaveCode(sqlitepp::Instance &db, const CodeData &data) {
136136 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 = ?;");
138138
139139 stmt.BindText(1, data.code);
140140 stmt.BindText(2, data.filename);
@@ -145,7 +145,7 @@
145145
146146 u32 GetLastShaderID(sqlitepp::Instance &db) {
147147 sqlitepp::Stmt stmt(db.GetDB());
148- stmt.Prepare("SELECT MAX(id) FROM shaders;");
148+ stmt.Prepare("SELECT MAX(id) FROM scenes;");
149149 return (stmt.Step() == SQLITE_ROW) ? stmt.ColumnInt(0) : 0;
150150 }
151151 } // namespace db