Fix for sqlite3 : Removes schema from database migrations
Removes the "castle." schema prefix from database table creation and index definitions in the migration file. This change enhances database portability by allowing the application to function correctly with different database configurations.
This commit is contained in:
parent
95b8af2360
commit
cdd0cda001
1 changed files with 11 additions and 13 deletions
|
|
@ -5,7 +5,7 @@ async def m001_initial(db):
|
||||||
"""
|
"""
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle.accounts (
|
CREATE TABLE accounts (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
account_type TEXT NOT NULL,
|
account_type TEXT NOT NULL,
|
||||||
|
|
@ -18,19 +18,19 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_accounts_user_id ON castle.accounts (user_id);
|
CREATE INDEX idx_accounts_user_id ON accounts (user_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_accounts_type ON castle.accounts (account_type);
|
CREATE INDEX idx_accounts_type ON accounts (account_type);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle.journal_entries (
|
CREATE TABLE journal_entries (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
description TEXT NOT NULL,
|
description TEXT NOT NULL,
|
||||||
entry_date TIMESTAMP NOT NULL,
|
entry_date TIMESTAMP NOT NULL,
|
||||||
|
|
@ -43,40 +43,38 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_journal_entries_created_by ON castle.journal_entries (created_by);
|
CREATE INDEX idx_journal_entries_created_by ON journal_entries (created_by);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_journal_entries_date ON castle.journal_entries (entry_date);
|
CREATE INDEX idx_journal_entries_date ON journal_entries (entry_date);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle.entry_lines (
|
CREATE TABLE entry_lines (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
journal_entry_id TEXT NOT NULL,
|
journal_entry_id TEXT NOT NULL,
|
||||||
account_id TEXT NOT NULL,
|
account_id TEXT NOT NULL,
|
||||||
debit INTEGER NOT NULL DEFAULT 0,
|
debit INTEGER NOT NULL DEFAULT 0,
|
||||||
credit INTEGER NOT NULL DEFAULT 0,
|
credit INTEGER NOT NULL DEFAULT 0,
|
||||||
description TEXT,
|
description TEXT
|
||||||
FOREIGN KEY (journal_entry_id) REFERENCES castle.journal_entries (id),
|
|
||||||
FOREIGN KEY (account_id) REFERENCES castle.accounts (id)
|
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_entry_lines_journal_entry ON castle.entry_lines (journal_entry_id);
|
CREATE INDEX idx_entry_lines_journal_entry ON entry_lines (journal_entry_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_entry_lines_account ON castle.entry_lines (account_id);
|
CREATE INDEX idx_entry_lines_account ON entry_lines (account_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -110,7 +108,7 @@ async def m001_initial(db):
|
||||||
for acc_id, name, acc_type, desc in default_accounts:
|
for acc_id, name, acc_type, desc in default_accounts:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO castle.accounts (id, name, account_type, description)
|
INSERT INTO accounts (id, name, account_type, description)
|
||||||
VALUES (:id, :name, :type, :description)
|
VALUES (:id, :name, :type, :description)
|
||||||
""",
|
""",
|
||||||
{"id": acc_id, "name": name, "type": acc_type, "description": desc}
|
{"id": acc_id, "name": name, "type": acc_type, "description": desc}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue