db: set various ip address columns to nullable.

Set various IP address columns to nullable in preparation for dropping them.

In production, some of these tables already contained null values even
though it violated the constraint.
This commit is contained in:
evazion
2022-09-17 22:46:23 -05:00
parent 553d35178c
commit 44d4452068
2 changed files with 29 additions and 11 deletions

View File

@@ -0,0 +1,17 @@
class ChangeIpAddressesToNullable < ActiveRecord::Migration[7.0]
def change
change_column_null :artist_versions, :updater_ip_addr, true
change_column_null :artist_commentary_versions, :updater_ip_addr, true
change_column_null :note_versions, :updater_ip_addr, true
change_column_null :wiki_page_versions, :updater_ip_addr, true
change_column_null :post_versions, :updater_ip_addr, true
change_column_null :pool_versions, :updater_ip_addr, true
change_column_null :comments, :creator_ip_addr, true
change_column_null :comments, :updater_ip_addr, true
change_column_null :dmails, :creator_ip_addr, true
change_column_null :posts, :uploader_ip_addr, true
change_column_null :uploads, :uploader_ip_addr, true
end
end

View File

@@ -195,7 +195,7 @@ CREATE TABLE public.artist_commentary_versions (
id integer NOT NULL,
post_id integer NOT NULL,
updater_id integer NOT NULL,
updater_ip_addr inet NOT NULL,
updater_ip_addr inet,
original_title text DEFAULT ''::text NOT NULL,
original_description text DEFAULT ''::text NOT NULL,
translated_title text DEFAULT ''::text NOT NULL,
@@ -269,7 +269,7 @@ CREATE TABLE public.artist_versions (
artist_id integer NOT NULL,
name character varying NOT NULL,
updater_id integer NOT NULL,
updater_ip_addr inet NOT NULL,
updater_ip_addr inet,
is_deleted boolean DEFAULT false NOT NULL,
other_names text[] DEFAULT '{}'::text[] NOT NULL,
group_name character varying DEFAULT ''::character varying NOT NULL,
@@ -453,7 +453,7 @@ CREATE TABLE public.comments (
post_id integer NOT NULL,
creator_id integer NOT NULL,
body text NOT NULL,
creator_ip_addr inet NOT NULL,
creator_ip_addr inet,
score integer DEFAULT 0 NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
@@ -500,7 +500,7 @@ CREATE TABLE public.dmails (
is_deleted boolean DEFAULT false NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
creator_ip_addr inet NOT NULL,
creator_ip_addr inet,
is_spam boolean DEFAULT false NOT NULL
);
@@ -1105,7 +1105,7 @@ CREATE TABLE public.note_versions (
width integer NOT NULL,
height integer NOT NULL,
body text NOT NULL,
updater_ip_addr inet NOT NULL,
updater_ip_addr inet,
is_active boolean DEFAULT true NOT NULL,
note_id integer NOT NULL,
post_id integer NOT NULL,
@@ -1216,7 +1216,7 @@ CREATE TABLE public.pool_versions (
updated_at timestamp(6) without time zone NOT NULL,
pool_id bigint NOT NULL,
updater_id bigint NOT NULL,
updater_ip_addr inet NOT NULL,
updater_ip_addr inet,
version integer DEFAULT 1 NOT NULL,
name text NOT NULL,
description text DEFAULT ''::text NOT NULL,
@@ -1481,7 +1481,7 @@ CREATE TABLE public.post_versions (
updated_at timestamp(6) without time zone NOT NULL,
post_id bigint NOT NULL,
updater_id bigint NOT NULL,
updater_ip_addr inet NOT NULL,
updater_ip_addr inet,
version integer DEFAULT 1 NOT NULL,
parent_changed boolean DEFAULT false NOT NULL,
rating_changed boolean DEFAULT false NOT NULL,
@@ -1564,7 +1564,7 @@ CREATE TABLE public.posts (
rating character(1) DEFAULT 'q'::bpchar NOT NULL,
image_width integer NOT NULL,
image_height integer NOT NULL,
uploader_ip_addr inet NOT NULL,
uploader_ip_addr inet,
tag_string text DEFAULT ''::text NOT NULL,
fav_count integer DEFAULT 0 NOT NULL,
file_ext character varying NOT NULL,
@@ -1921,7 +1921,7 @@ CREATE TABLE public.uploads (
id integer NOT NULL,
source text,
uploader_id integer NOT NULL,
uploader_ip_addr inet NOT NULL,
uploader_ip_addr inet,
status text DEFAULT 'pending'::text NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
@@ -2056,7 +2056,7 @@ CREATE TABLE public.wiki_page_versions (
title character varying NOT NULL,
body text NOT NULL,
updater_id integer NOT NULL,
updater_ip_addr inet NOT NULL,
updater_ip_addr inet,
wiki_page_id integer NOT NULL,
is_locked boolean NOT NULL,
other_names text[] DEFAULT '{}'::text[] NOT NULL,
@@ -6693,6 +6693,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220909211649'),
('20220913191300'),
('20220913191309'),
('20220917204044');
('20220917204044'),
('20220918031429');