MIGRATION FIX: remove castle_ prefixes
This commit is contained in:
parent
7506b0250f
commit
ff6853a030
1 changed files with 34 additions and 34 deletions
|
|
@ -63,7 +63,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 UNIQUE,
|
name TEXT NOT NULL UNIQUE,
|
||||||
account_type TEXT NOT NULL,
|
account_type TEXT NOT NULL,
|
||||||
|
|
@ -76,13 +76,13 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_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_castle_accounts_type ON castle_accounts (account_type);
|
CREATE INDEX idx_accounts_type ON accounts (account_type);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle_extension_settings (
|
CREATE TABLE extension_settings (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
castle_wallet_id TEXT,
|
castle_wallet_id TEXT,
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
updated_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
||||||
|
|
@ -108,7 +108,7 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle_user_wallet_settings (
|
CREATE TABLE user_wallet_settings (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
user_wallet_id TEXT,
|
user_wallet_id TEXT,
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
updated_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
||||||
|
|
@ -123,7 +123,7 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle_manual_payment_requests (
|
CREATE TABLE manual_payment_requests (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
user_id TEXT NOT NULL,
|
user_id TEXT NOT NULL,
|
||||||
amount INTEGER NOT NULL,
|
amount INTEGER NOT NULL,
|
||||||
|
|
@ -140,15 +140,15 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_manual_payment_requests_user_id
|
CREATE INDEX idx_manual_payment_requests_user_id
|
||||||
ON castle_manual_payment_requests (user_id);
|
ON manual_payment_requests (user_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_manual_payment_requests_status
|
CREATE INDEX idx_manual_payment_requests_status
|
||||||
ON castle_manual_payment_requests (status);
|
ON manual_payment_requests (status);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle_balance_assertions (
|
CREATE TABLE balance_assertions (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
date TIMESTAMP NOT NULL,
|
date TIMESTAMP NOT NULL,
|
||||||
account_id TEXT NOT NULL,
|
account_id TEXT NOT NULL,
|
||||||
|
|
@ -178,29 +178,29 @@ async def m001_initial(db):
|
||||||
created_by TEXT NOT NULL,
|
created_by TEXT NOT NULL,
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
created_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
||||||
checked_at TIMESTAMP,
|
checked_at TIMESTAMP,
|
||||||
FOREIGN KEY (account_id) REFERENCES castle_accounts (id)
|
FOREIGN KEY (account_id) REFERENCES accounts (id)
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_balance_assertions_account_id
|
CREATE INDEX idx_balance_assertions_account_id
|
||||||
ON castle_balance_assertions (account_id);
|
ON balance_assertions (account_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_balance_assertions_status
|
CREATE INDEX idx_balance_assertions_status
|
||||||
ON castle_balance_assertions (status);
|
ON balance_assertions (status);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_balance_assertions_date
|
CREATE INDEX idx_balance_assertions_date
|
||||||
ON castle_balance_assertions (date);
|
ON balance_assertions (date);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle_user_equity_status (
|
CREATE TABLE user_equity_status (
|
||||||
user_id TEXT PRIMARY KEY,
|
user_id TEXT PRIMARY KEY,
|
||||||
is_equity_eligible BOOLEAN NOT NULL DEFAULT FALSE,
|
is_equity_eligible BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
equity_account_name TEXT,
|
equity_account_name TEXT,
|
||||||
|
|
@ -227,8 +227,8 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_user_equity_status_eligible
|
CREATE INDEX idx_user_equity_status_eligible
|
||||||
ON castle_user_equity_status (is_equity_eligible)
|
ON user_equity_status (is_equity_eligible)
|
||||||
WHERE is_equity_eligible = TRUE;
|
WHERE is_equity_eligible = TRUE;
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
@ -242,7 +242,7 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
CREATE TABLE castle_account_permissions (
|
CREATE TABLE account_permissions (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
user_id TEXT NOT NULL,
|
user_id TEXT NOT NULL,
|
||||||
account_id TEXT NOT NULL,
|
account_id TEXT NOT NULL,
|
||||||
|
|
@ -251,7 +251,7 @@ async def m001_initial(db):
|
||||||
granted_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
granted_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
||||||
expires_at TIMESTAMP,
|
expires_at TIMESTAMP,
|
||||||
notes TEXT,
|
notes TEXT,
|
||||||
FOREIGN KEY (account_id) REFERENCES castle_accounts (id)
|
FOREIGN KEY (account_id) REFERENCES accounts (id)
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
@ -259,40 +259,40 @@ async def m001_initial(db):
|
||||||
# Index for looking up permissions by user
|
# Index for looking up permissions by user
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_account_permissions_user_id
|
CREATE INDEX idx_account_permissions_user_id
|
||||||
ON castle_account_permissions (user_id);
|
ON account_permissions (user_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Index for looking up permissions by account
|
# Index for looking up permissions by account
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_account_permissions_account_id
|
CREATE INDEX idx_account_permissions_account_id
|
||||||
ON castle_account_permissions (account_id);
|
ON account_permissions (account_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Composite index for checking specific user+account permissions
|
# Composite index for checking specific user+account permissions
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_account_permissions_user_account
|
CREATE INDEX idx_account_permissions_user_account
|
||||||
ON castle_account_permissions (user_id, account_id);
|
ON account_permissions (user_id, account_id);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Index for finding permissions by type
|
# Index for finding permissions by type
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_account_permissions_type
|
CREATE INDEX idx_account_permissions_type
|
||||||
ON castle_account_permissions (permission_type);
|
ON account_permissions (permission_type);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Index for finding expired permissions
|
# Index for finding expired permissions
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX idx_castle_account_permissions_expires
|
CREATE INDEX idx_account_permissions_expires
|
||||||
ON castle_account_permissions (expires_at)
|
ON account_permissions (expires_at)
|
||||||
WHERE expires_at IS NOT NULL;
|
WHERE expires_at IS NOT NULL;
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
@ -315,7 +315,7 @@ async def m001_initial(db):
|
||||||
for name, account_type, description in DEFAULT_HIERARCHICAL_ACCOUNTS:
|
for name, account_type, description in DEFAULT_HIERARCHICAL_ACCOUNTS:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
f"""
|
f"""
|
||||||
INSERT INTO castle_accounts (id, name, account_type, description, created_at)
|
INSERT INTO accounts (id, name, account_type, description, created_at)
|
||||||
VALUES (:id, :name, :type, :description, {db.timestamp_now})
|
VALUES (:id, :name, :type, :description, {db.timestamp_now})
|
||||||
""",
|
""",
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue