diff options
| author | soryu <soryu@soryu.co> | 2026-01-06 04:08:11 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-11 03:01:13 +0000 |
| commit | 8b17a175c3e7e27b789812eba4e3cd760beadb10 (patch) | |
| tree | 7864dcaa2fa9db47fdfd4e8bfdb0b1dde832aa33 /makima/migrations/20250110000008_remove_owner_defaults.sql | |
| parent | f79c416c58557d2f946aa5332989afdfa8c021cd (diff) | |
| download | soryu-8b17a175c3e7e27b789812eba4e3cd760beadb10.tar.gz soryu-8b17a175c3e7e27b789812eba4e3cd760beadb10.zip | |
Initial Control system
Diffstat (limited to 'makima/migrations/20250110000008_remove_owner_defaults.sql')
| -rw-r--r-- | makima/migrations/20250110000008_remove_owner_defaults.sql | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/makima/migrations/20250110000008_remove_owner_defaults.sql b/makima/migrations/20250110000008_remove_owner_defaults.sql new file mode 100644 index 0000000..307f077 --- /dev/null +++ b/makima/migrations/20250110000008_remove_owner_defaults.sql @@ -0,0 +1,46 @@ +-- Remove default owner_id values from tables +-- This should be done after application code is updated to always provide owner_id + +-- IMPORTANT: Only apply this migration after updating all code to provide owner_id +-- Otherwise, inserts will fail + +-- Remove default values (they are no longer needed since code provides owner_id) +ALTER TABLE files + ALTER COLUMN owner_id DROP DEFAULT; + +ALTER TABLE tasks + ALTER COLUMN owner_id DROP DEFAULT; + +ALTER TABLE daemons + ALTER COLUMN owner_id DROP DEFAULT; + +ALTER TABLE mesh_chat_conversations + ALTER COLUMN owner_id DROP DEFAULT; + +-- Make owner_id NOT NULL explicit (should already be, but ensure) +-- Note: These columns were created with NOT NULL, so this is a no-op validation +-- The SET NOT NULL will succeed if all existing rows have non-null values + +-- Files already has NOT NULL in original migration (20241222000000) +-- Tasks already has NOT NULL in original migration (20250102000000) +-- Daemons already has NOT NULL in original migration (20250102000000) +-- Mesh chat conversations already has NOT NULL in original migration (20250104000000) + +-- However, we explicitly restate it for clarity and documentation +ALTER TABLE files + ALTER COLUMN owner_id SET NOT NULL; + +ALTER TABLE tasks + ALTER COLUMN owner_id SET NOT NULL; + +ALTER TABLE daemons + ALTER COLUMN owner_id SET NOT NULL; + +ALTER TABLE mesh_chat_conversations + ALTER COLUMN owner_id SET NOT NULL; + +-- Add comments documenting the constraint +COMMENT ON COLUMN files.owner_id IS 'Owner ID is required - no default value, must be provided by application'; +COMMENT ON COLUMN tasks.owner_id IS 'Owner ID is required - no default value, must be provided by application'; +COMMENT ON COLUMN daemons.owner_id IS 'Owner ID is required - no default value, must be provided by application'; +COMMENT ON COLUMN mesh_chat_conversations.owner_id IS 'Owner ID is required - no default value, must be provided by application'; |
