Skip to content

Add NOT NULL constraint to notes.namespace_id

What does this MR do and why?

Having deleted any records with potentially empty namespace_id values in %17.2, this MR adds a NOT NULL constraint to notes.namespace_id to support eventual sharding.

Related to #444222

Database

Up

main: == [advisory_lock_connection] object_id: 130600, pg_backend_pid: 64945
main: == 20240725164304 AddNotNullToNotesOnNamespaceId: migrating ===================
main: -- current_schema(nil)
main:    -> 0.0009s
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.0008s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- execute("ALTER TABLE notes VALIDATE CONSTRAINT check_8fd7763725;")
main:    -> 0.0005s
main: -- execute("RESET statement_timeout")
main:    -> 0.0001s
main: == 20240725164304 AddNotNullToNotesOnNamespaceId: migrated (0.0365s) ==========

main: == [advisory_lock_connection] object_id: 130600, pg_backend_pid: 64945

Down

main: == [advisory_lock_connection] object_id: 130320, pg_backend_pid: 64793
main: == 20240725164304 AddNotNullToNotesOnNamespaceId: 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: == 20240725164304 AddNotNullToNotesOnNamespaceId: reverted (0.0136s) ==========

main: == [advisory_lock_connection] object_id: 130320, pg_backend_pid: 64793
Edited by Kerri Miller

Merge request reports

Loading