Delet Subcategory Function
This commit is contained in:
@@ -165,7 +165,6 @@ const initDb = async () => {
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
location_id INTEGER NOT NULL,
|
||||
category_id INTEGER NOT NULL,
|
||||
subcategory_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
private_data TEXT,
|
||||
@@ -177,8 +176,7 @@ const initDb = async () => {
|
||||
hidden_description TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (location_id) REFERENCES locations(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (subcategory_id) REFERENCES subcategories(id) ON DELETE CASCADE
|
||||
FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE
|
||||
)
|
||||
`);
|
||||
|
||||
@@ -222,18 +220,6 @@ const initDb = async () => {
|
||||
)
|
||||
`);
|
||||
|
||||
// Create subcategories table
|
||||
await db.runAsync(`
|
||||
CREATE TABLE IF NOT EXISTS subcategories (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
category_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE,
|
||||
UNIQUE(category_id, name)
|
||||
)
|
||||
`);
|
||||
|
||||
// Commit transaction
|
||||
await db.runAsync('COMMIT');
|
||||
console.log('Database tables initialized successfully');
|
||||
|
||||
Reference in New Issue
Block a user