From fb0b654e11946cb7467c78564d7abfc50d608568 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 22 Dec 2020 20:07:30 +0000 Subject: [PATCH] Update 20201203213108_add_unread_count_to_chat_conversation_accounts_not_null.rb --- ...d_count_to_chat_conversation_accounts_not_null.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/migrate/20201203213108_add_unread_count_to_chat_conversation_accounts_not_null.rb b/db/migrate/20201203213108_add_unread_count_to_chat_conversation_accounts_not_null.rb index 95687dcd..361e0206 100644 --- a/db/migrate/20201203213108_add_unread_count_to_chat_conversation_accounts_not_null.rb +++ b/db/migrate/20201203213108_add_unread_count_to_chat_conversation_accounts_not_null.rb @@ -1,5 +1,15 @@ class AddUnreadCountToChatConversationAccountsNotNull < ActiveRecord::Migration[5.2] def change - change_column_null :chat_conversation_accounts, :unread_count, false + safety_assured do + execute 'ALTER TABLE "chat_conversation_accounts" ADD CONSTRAINT "chat_conversation_accounts_unread_count_null" CHECK ("unread_count" IS NOT NULL) NOT VALID' + end end end + +class ValidateAddUnreadCountToChatConversationAccountsNotNull < ActiveRecord::Migration[5.2] + def change + safety_assured do + execute 'ALTER TABLE "chat_conversation_accounts" VALIDATE CONSTRAINT "chat_conversation_accounts_unread_count_null"' + end + end +end \ No newline at end of file