Rename PostgreSQL function into "is_good_text"
This commit is contained in:
parent
7a48bf65ff
commit
c2c243fcc3
2 changed files with 43 additions and 43 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
class InitialMigration < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
func :has_no_leading_trailing_whitespace, <<~SQL
|
||||
func :is_good_text, <<~SQL
|
||||
(str text) RETURNS boolean IMMUTABLE LANGUAGE plpgsql AS
|
||||
$$
|
||||
BEGIN
|
||||
|
@ -238,7 +238,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(public_name) BETWEEN 3 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(public_name)
|
||||
is_good_text(public_name)
|
||||
SQL
|
||||
|
||||
constraint :accounts, :biography, <<~SQL
|
||||
|
@ -246,25 +246,25 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(biography) BETWEEN 3 AND 10000
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(biography)
|
||||
is_good_text(biography)
|
||||
SQL
|
||||
|
||||
constraint :federal_subjects, :english_name, <<~SQL
|
||||
length(english_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(english_name)
|
||||
is_good_text(english_name)
|
||||
SQL
|
||||
|
||||
constraint :federal_subjects, :native_name, <<~SQL
|
||||
length(native_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(native_name)
|
||||
is_good_text(native_name)
|
||||
SQL
|
||||
|
||||
constraint :federal_subjects, :centre, <<~SQL
|
||||
length(centre) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(centre)
|
||||
is_good_text(centre)
|
||||
SQL
|
||||
|
||||
constraint :federal_subjects, :number, <<~SQL
|
||||
|
@ -276,7 +276,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(zip_code) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(zip_code)
|
||||
is_good_text(zip_code)
|
||||
SQL
|
||||
|
||||
constraint :passports, :town_type, <<~SQL
|
||||
|
@ -284,7 +284,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(town_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(town_type)
|
||||
is_good_text(town_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :town_name, <<~SQL
|
||||
|
@ -292,7 +292,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(town_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(town_name)
|
||||
is_good_text(town_name)
|
||||
SQL
|
||||
|
||||
constraint :passports, :settlement_type, <<~SQL
|
||||
|
@ -300,7 +300,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(settlement_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(settlement_type)
|
||||
is_good_text(settlement_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :settlement_name, <<~SQL
|
||||
|
@ -308,7 +308,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(settlement_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(settlement_name)
|
||||
is_good_text(settlement_name)
|
||||
SQL
|
||||
|
||||
constraint :passports, :district_type, <<~SQL
|
||||
|
@ -316,7 +316,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(district_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(district_type)
|
||||
is_good_text(district_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :district_name, <<~SQL
|
||||
|
@ -324,7 +324,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(district_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(district_name)
|
||||
is_good_text(district_name)
|
||||
SQL
|
||||
|
||||
constraint :passports, :street_type, <<~SQL
|
||||
|
@ -332,7 +332,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(street_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(street_type)
|
||||
is_good_text(street_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :street_name, <<~SQL
|
||||
|
@ -340,7 +340,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(street_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(street_name)
|
||||
is_good_text(street_name)
|
||||
SQL
|
||||
|
||||
constraint :passports, :residence_type, <<~SQL
|
||||
|
@ -348,7 +348,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(residence_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(residence_type)
|
||||
is_good_text(residence_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :residence_name, <<~SQL
|
||||
|
@ -356,7 +356,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(residence_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(residence_name)
|
||||
is_good_text(residence_name)
|
||||
SQL
|
||||
|
||||
constraint :passports, :building_type, <<~SQL
|
||||
|
@ -364,7 +364,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(building_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(building_type)
|
||||
is_good_text(building_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :building_name, <<~SQL
|
||||
|
@ -372,7 +372,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(building_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(building_name)
|
||||
is_good_text(building_name)
|
||||
SQL
|
||||
|
||||
constraint :passports, :apartment_type, <<~SQL
|
||||
|
@ -380,7 +380,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(apartment_type) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(apartment_type)
|
||||
is_good_text(apartment_type)
|
||||
SQL
|
||||
|
||||
constraint :passports, :apartment_name, <<~SQL
|
||||
|
@ -388,7 +388,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
OR
|
||||
length(apartment_name) BETWEEN 1 AND 255
|
||||
AND
|
||||
has_no_leading_trailing_whitespace(apartment_name)
|
||||
is_good_text(apartment_name)
|
||||
SQL
|
||||
end
|
||||
|
||||
|
|
|
@ -70,10 +70,10 @@ CREATE TYPE public.sex AS ENUM (
|
|||
|
||||
|
||||
--
|
||||
-- Name: has_no_leading_trailing_whitespace(text); Type: FUNCTION; Schema: public; Owner: -
|
||||
-- Name: is_good_text(text); Type: FUNCTION; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE FUNCTION public.has_no_leading_trailing_whitespace(str text) RETURNS boolean
|
||||
CREATE FUNCTION public.is_good_text(str text) RETURNS boolean
|
||||
LANGUAGE plpgsql IMMUTABLE
|
||||
AS $_$
|
||||
BEGIN
|
||||
|
@ -134,10 +134,10 @@ CREATE TABLE public.accounts (
|
|||
biography text,
|
||||
person_id bigint,
|
||||
contacts_list_id bigint NOT NULL,
|
||||
CONSTRAINT biography CHECK (((biography IS NULL) OR (((length(biography) >= 3) AND (length(biography) <= 10000)) AND public.has_no_leading_trailing_whitespace(biography)))),
|
||||
CONSTRAINT biography CHECK (((biography IS NULL) OR (((length(biography) >= 3) AND (length(biography) <= 10000)) AND public.is_good_text(biography)))),
|
||||
CONSTRAINT guest_token CHECK (((guest_token)::text ~ '^[0-9a-f]{32}$'::text)),
|
||||
CONSTRAINT nickname CHECK ((((length((nickname)::text) >= 3) AND (length((nickname)::text) <= 36)) AND ((nickname)::text ~ '^[a-z][a-z0-9]*(_[a-z0-9]+)*$'::text))),
|
||||
CONSTRAINT public_name CHECK (((public_name IS NULL) OR (((length((public_name)::text) >= 3) AND (length((public_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((public_name)::text))))
|
||||
CONSTRAINT public_name CHECK (((public_name IS NULL) OR (((length((public_name)::text) >= 3) AND (length((public_name)::text) <= 255)) AND public.is_good_text((public_name)::text))))
|
||||
);
|
||||
|
||||
|
||||
|
@ -283,9 +283,9 @@ CREATE TABLE public.federal_subjects (
|
|||
centre character varying NOT NULL,
|
||||
number integer NOT NULL,
|
||||
timezone interval NOT NULL,
|
||||
CONSTRAINT centre CHECK ((((length((centre)::text) >= 1) AND (length((centre)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((centre)::text))),
|
||||
CONSTRAINT english_name CHECK ((((length((english_name)::text) >= 1) AND (length((english_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((english_name)::text))),
|
||||
CONSTRAINT native_name CHECK ((((length((native_name)::text) >= 1) AND (length((native_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((native_name)::text))),
|
||||
CONSTRAINT centre CHECK ((((length((centre)::text) >= 1) AND (length((centre)::text) <= 255)) AND public.is_good_text((centre)::text))),
|
||||
CONSTRAINT english_name CHECK ((((length((english_name)::text) >= 1) AND (length((english_name)::text) <= 255)) AND public.is_good_text((english_name)::text))),
|
||||
CONSTRAINT native_name CHECK ((((length((native_name)::text) >= 1) AND (length((native_name)::text) <= 255)) AND public.is_good_text((native_name)::text))),
|
||||
CONSTRAINT number CHECK ((number > 0))
|
||||
);
|
||||
|
||||
|
@ -345,21 +345,21 @@ CREATE TABLE public.passports (
|
|||
building_name character varying,
|
||||
apartment_type character varying,
|
||||
apartment_name character varying,
|
||||
CONSTRAINT apartment_name CHECK (((apartment_name IS NULL) OR (((length((apartment_name)::text) >= 1) AND (length((apartment_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((apartment_name)::text)))),
|
||||
CONSTRAINT apartment_type CHECK (((apartment_type IS NULL) OR (((length((apartment_type)::text) >= 1) AND (length((apartment_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((apartment_type)::text)))),
|
||||
CONSTRAINT building_name CHECK (((building_name IS NULL) OR (((length((building_name)::text) >= 1) AND (length((building_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((building_name)::text)))),
|
||||
CONSTRAINT building_type CHECK (((building_type IS NULL) OR (((length((building_type)::text) >= 1) AND (length((building_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((building_type)::text)))),
|
||||
CONSTRAINT district_name CHECK (((district_name IS NULL) OR (((length((district_name)::text) >= 1) AND (length((district_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((district_name)::text)))),
|
||||
CONSTRAINT district_type CHECK (((district_type IS NULL) OR (((length((district_type)::text) >= 1) AND (length((district_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((district_type)::text)))),
|
||||
CONSTRAINT residence_name CHECK (((residence_name IS NULL) OR (((length((residence_name)::text) >= 1) AND (length((residence_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((residence_name)::text)))),
|
||||
CONSTRAINT residence_type CHECK (((residence_type IS NULL) OR (((length((residence_type)::text) >= 1) AND (length((residence_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((residence_type)::text)))),
|
||||
CONSTRAINT settlement_name CHECK (((settlement_name IS NULL) OR (((length((settlement_name)::text) >= 1) AND (length((settlement_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((settlement_name)::text)))),
|
||||
CONSTRAINT settlement_type CHECK (((settlement_type IS NULL) OR (((length((settlement_type)::text) >= 1) AND (length((settlement_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((settlement_type)::text)))),
|
||||
CONSTRAINT street_name CHECK (((street_name IS NULL) OR (((length((street_name)::text) >= 1) AND (length((street_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((street_name)::text)))),
|
||||
CONSTRAINT street_type CHECK (((street_type IS NULL) OR (((length((street_type)::text) >= 1) AND (length((street_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((street_type)::text)))),
|
||||
CONSTRAINT town_name CHECK (((town_name IS NULL) OR (((length((town_name)::text) >= 1) AND (length((town_name)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((town_name)::text)))),
|
||||
CONSTRAINT town_type CHECK (((town_type IS NULL) OR (((length((town_type)::text) >= 1) AND (length((town_type)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((town_type)::text)))),
|
||||
CONSTRAINT zip_code CHECK (((zip_code IS NULL) OR (((length((zip_code)::text) >= 1) AND (length((zip_code)::text) <= 255)) AND public.has_no_leading_trailing_whitespace((zip_code)::text))))
|
||||
CONSTRAINT apartment_name CHECK (((apartment_name IS NULL) OR (((length((apartment_name)::text) >= 1) AND (length((apartment_name)::text) <= 255)) AND public.is_good_text((apartment_name)::text)))),
|
||||
CONSTRAINT apartment_type CHECK (((apartment_type IS NULL) OR (((length((apartment_type)::text) >= 1) AND (length((apartment_type)::text) <= 255)) AND public.is_good_text((apartment_type)::text)))),
|
||||
CONSTRAINT building_name CHECK (((building_name IS NULL) OR (((length((building_name)::text) >= 1) AND (length((building_name)::text) <= 255)) AND public.is_good_text((building_name)::text)))),
|
||||
CONSTRAINT building_type CHECK (((building_type IS NULL) OR (((length((building_type)::text) >= 1) AND (length((building_type)::text) <= 255)) AND public.is_good_text((building_type)::text)))),
|
||||
CONSTRAINT district_name CHECK (((district_name IS NULL) OR (((length((district_name)::text) >= 1) AND (length((district_name)::text) <= 255)) AND public.is_good_text((district_name)::text)))),
|
||||
CONSTRAINT district_type CHECK (((district_type IS NULL) OR (((length((district_type)::text) >= 1) AND (length((district_type)::text) <= 255)) AND public.is_good_text((district_type)::text)))),
|
||||
CONSTRAINT residence_name CHECK (((residence_name IS NULL) OR (((length((residence_name)::text) >= 1) AND (length((residence_name)::text) <= 255)) AND public.is_good_text((residence_name)::text)))),
|
||||
CONSTRAINT residence_type CHECK (((residence_type IS NULL) OR (((length((residence_type)::text) >= 1) AND (length((residence_type)::text) <= 255)) AND public.is_good_text((residence_type)::text)))),
|
||||
CONSTRAINT settlement_name CHECK (((settlement_name IS NULL) OR (((length((settlement_name)::text) >= 1) AND (length((settlement_name)::text) <= 255)) AND public.is_good_text((settlement_name)::text)))),
|
||||
CONSTRAINT settlement_type CHECK (((settlement_type IS NULL) OR (((length((settlement_type)::text) >= 1) AND (length((settlement_type)::text) <= 255)) AND public.is_good_text((settlement_type)::text)))),
|
||||
CONSTRAINT street_name CHECK (((street_name IS NULL) OR (((length((street_name)::text) >= 1) AND (length((street_name)::text) <= 255)) AND public.is_good_text((street_name)::text)))),
|
||||
CONSTRAINT street_type CHECK (((street_type IS NULL) OR (((length((street_type)::text) >= 1) AND (length((street_type)::text) <= 255)) AND public.is_good_text((street_type)::text)))),
|
||||
CONSTRAINT town_name CHECK (((town_name IS NULL) OR (((length((town_name)::text) >= 1) AND (length((town_name)::text) <= 255)) AND public.is_good_text((town_name)::text)))),
|
||||
CONSTRAINT town_type CHECK (((town_type IS NULL) OR (((length((town_type)::text) >= 1) AND (length((town_type)::text) <= 255)) AND public.is_good_text((town_type)::text)))),
|
||||
CONSTRAINT zip_code CHECK (((zip_code IS NULL) OR (((length((zip_code)::text) >= 1) AND (length((zip_code)::text) <= 255)) AND public.is_good_text((zip_code)::text))))
|
||||
);
|
||||
|
||||
|
||||
|
|
Reference in a new issue