[init] Add initial database migration files for PostgreSQL, SQLite, and MySQL
This commit is contained in:
36
api/migrations/postgresql/001_init.down.sql
Normal file
36
api/migrations/postgresql/001_init.down.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- ===========
|
||||
-- Down Migration
|
||||
-- ===========
|
||||
|
||||
-- Drop triggers (must be dropped before their tables)
|
||||
DROP TRIGGER IF EXISTS update_routes_updated_at ON routes;
|
||||
DROP TRIGGER IF EXISTS update_projects_updated_at ON projects;
|
||||
DROP TRIGGER IF EXISTS update_workspaces_updated_at ON workspaces;
|
||||
DROP TRIGGER IF EXISTS update_plans_updated_at ON plans;
|
||||
DROP TRIGGER IF EXISTS update_users_updated_at ON users;
|
||||
|
||||
-- Drop the trigger function (after all triggers are gone)
|
||||
DROP FUNCTION IF EXISTS update_updated_at_column();
|
||||
|
||||
-- Drop indexes
|
||||
DROP INDEX IF EXISTS idx_routes_project_id;
|
||||
DROP INDEX IF EXISTS idx_projects_workspace_id;
|
||||
DROP INDEX IF EXISTS idx_workspaces_owner_id;
|
||||
|
||||
-- Drop tables in reverse dependency order
|
||||
-- Product Logic
|
||||
DROP TABLE IF EXISTS routes;
|
||||
DROP TABLE IF EXISTS projects;
|
||||
|
||||
-- RBAC
|
||||
DROP TABLE IF EXISTS role_permissions;
|
||||
DROP TABLE IF EXISTS permissions;
|
||||
DROP TABLE IF EXISTS roles;
|
||||
|
||||
-- Tenancy
|
||||
DROP TABLE IF EXISTS workspace_members;
|
||||
DROP TABLE IF EXISTS workspaces;
|
||||
|
||||
-- Users & Plans
|
||||
DROP TABLE IF EXISTS plans;
|
||||
DROP TABLE IF EXISTS users;
|
Reference in New Issue
Block a user