Skip to content

Add not null constraint to notes namespace_id

Heinrich Lee Yu requested to merge 416127-not-null-namespace-id into master

What does this MR do and why?

Add not null constraint to notes namespace_id. This is part of the work to partition the notes table.

Migration Output
main: == [advisory_lock_connection] object_id: 227080, pg_backend_pid: 68651
main: == 20231012005128 AddNotNullNotesNamespaceId: migrating =======================
main: -- current_schema(nil)
main:    -> 0.0016s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE notes\nADD CONSTRAINT check_8fd7763725\nCHECK ( namespace_id IS NOT NULL )\nNOT VALID;\n")
main:    -> 0.0009s
main: == 20231012005128 AddNotNullNotesNamespaceId: migrated (0.2276s) ==============

main: == [advisory_lock_connection] object_id: 227080, pg_backend_pid: 68651
ci: == [advisory_lock_connection] object_id: 227320, pg_backend_pid: 68654
ci: == 20231012005128 AddNotNullNotesNamespaceId: migrating =======================
ci: -- current_schema(nil)
ci:    -> 0.0004s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE notes\nADD CONSTRAINT check_8fd7763725\nCHECK ( namespace_id IS NOT NULL )\nNOT VALID;\n")
ci:    -> 0.0010s
ci: == 20231012005128 AddNotNullNotesNamespaceId: migrated (0.0221s) ==============

ci: == [advisory_lock_connection] object_id: 227320, pg_backend_pid: 68654
ci: == [advisory_lock_connection] object_id: 226700, pg_backend_pid: 69392
ci: == 20231012005128 AddNotNullNotesNamespaceId: reverting =======================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("            ALTER TABLE notes\n            DROP CONSTRAINT IF EXISTS check_8fd7763725\n")
ci:    -> 0.0007s
ci: == 20231012005128 AddNotNullNotesNamespaceId: reverted (0.0179s) ==============

ci: == [advisory_lock_connection] object_id: 226700, pg_backend_pid: 69392
main: == [advisory_lock_connection] object_id: 226660, pg_backend_pid: 69959
main: == 20231012005128 AddNotNullNotesNamespaceId: reverting =======================
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("            ALTER TABLE notes\n            DROP CONSTRAINT IF EXISTS check_8fd7763725\n")
main:    -> 0.0006s
main: == 20231012005128 AddNotNullNotesNamespaceId: reverted (0.0133s) ==============

main: == [advisory_lock_connection] object_id: 226660, pg_backend_pid: 69959

Related to #416127 (closed)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Heinrich Lee Yu

Merge request reports