happen remains to be seen.
$$;
+CREATE TYPE config.marc_record_type AS ENUM ('biblio', 'authority', 'serial');
+
CREATE TABLE config.marc_field (
id SERIAL PRIMARY KEY,
marc_format INTEGER NOT NULL
REFERENCES config.marc_format (id) DEFERRABLE INITIALLY DEFERRED,
- marc_record_type TEXT NOT NULL CHECK (
- marc_record_type IN ('biblio', 'authority', 'serial')
- ),
+ marc_record_type config.marc_record_type NOT NULL,
tag CHAR(3) NOT NULL,
name TEXT,
description TEXT,
id SERIAL PRIMARY KEY,
marc_format INTEGER NOT NULL
REFERENCES config.marc_format (id) DEFERRABLE INITIALLY DEFERRED,
- marc_record_type TEXT NOT NULL CHECK (
- marc_record_type IN ('biblio', 'authority', 'serial')
- ),
+ marc_record_type config.marc_record_type NOT NULL,
tag CHAR(3) NOT NULL,
code CHAR(1) NOT NULL,
description TEXT,
-- as well as any purely local ones that have been added
SELECT id, marc_format, marc_record_type, tag, name, description, fixed_field, repeatable, mandatory, hidden, owner, 0
FROM config.marc_field
- WHERE ARRAY[marc_format::TEXT, marc_record_type, tag] NOT IN (
- SELECT ARRAY[marc_format::TEXT, marc_record_type, tag]
+ WHERE ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag] NOT IN (
+ SELECT ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag]
FROM config.marc_field
WHERE owner IS NULL
)
-- as well as any purely local ones that have been added
SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner, 0
FROM config.marc_subfield
- WHERE ARRAY[marc_format::TEXT, marc_record_type, tag, code] NOT IN (
- SELECT ARRAY[marc_format::TEXT, marc_record_type, tag, code]
+ WHERE ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code] NOT IN (
+ SELECT ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code]
FROM config.marc_subfield
WHERE owner IS NULL
)
mandatory, hidden, owner, depth
FROM ou_marc_subfields;
-CREATE OR REPLACE FUNCTION config.ou_marc_fields(marc_format INTEGER, marc_record_type TEXT, ou INTEGER) RETURNS SETOF config.marc_field AS $func$
+CREATE OR REPLACE FUNCTION config.ou_marc_fields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_field AS $func$
SELECT id, marc_format, marc_record_type, tag, name, description, fixed_field, repeatable, mandatory, hidden, owner
FROM (
SELECT id, marc_format, marc_record_type, tag, name, description,
AND not hidden;
$func$ LANGUAGE SQL;
-CREATE OR REPLACE FUNCTION config.ou_marc_subfields(marc_format INTEGER, marc_record_type TEXT, ou INTEGER) RETURNS SETOF config.marc_subfield AS $func$
+CREATE OR REPLACE FUNCTION config.ou_marc_subfields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_subfield AS $func$
SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner
FROM (
SELECT id, marc_format, marc_record_type, tag, code, description,
-- FIXME: the following drop commands are present purely as
-- a convenience for development; they should be removed
-- before committing to master.
+DROP TYPE IF EXISTS config.marc_record_type CASCADE;
DROP FUNCTION IF EXISTS config.ou_marc_fields(INTEGER, TEXT, INTEGER);
DROP FUNCTION IF EXISTS config.ou_marc_subfields(INTEGER, TEXT, INTEGER);
+DROP FUNCTION IF EXISTS config.ou_marc_fields(INTEGER, config.marc_record_type, INTEGER);
+DROP FUNCTION IF EXISTS config.ou_marc_subfields(INTEGER, config.marc_record_type, INTEGER);
DROP VIEW IF EXISTS config.marc_field_for_ou;
DROP VIEW IF EXISTS config.marc_subfield_for_ou;
DROP TABLE IF EXISTS config.marc_subfield;
happen remains to be seen.
$$;
+CREATE TYPE config.marc_record_type AS ENUM ('biblio', 'authority', 'serial');
+
CREATE TABLE config.marc_field (
id SERIAL PRIMARY KEY,
marc_format INTEGER NOT NULL
REFERENCES config.marc_format (id) DEFERRABLE INITIALLY DEFERRED,
- marc_record_type TEXT NOT NULL CHECK (
- marc_record_type IN ('biblio', 'authority', 'serial')
- ),
+ marc_record_type config.marc_record_type NOT NULL,
tag CHAR(3) NOT NULL,
name TEXT,
description TEXT,
id SERIAL PRIMARY KEY,
marc_format INTEGER NOT NULL
REFERENCES config.marc_format (id) DEFERRABLE INITIALLY DEFERRED,
- marc_record_type TEXT NOT NULL CHECK (
- marc_record_type IN ('biblio', 'authority', 'serial')
- ),
+ marc_record_type config.marc_record_type NOT NULL,
tag CHAR(3) NOT NULL,
code CHAR(1) NOT NULL,
description TEXT,
-- as well as any purely local ones that have been added
SELECT id, marc_format, marc_record_type, tag, name, description, fixed_field, repeatable, mandatory, hidden, owner, 0
FROM config.marc_field
- WHERE ARRAY[marc_format::TEXT, marc_record_type, tag] NOT IN (
- SELECT ARRAY[marc_format::TEXT, marc_record_type, tag]
+ WHERE ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag] NOT IN (
+ SELECT ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag]
FROM config.marc_field
WHERE owner IS NULL
)
-- as well as any purely local ones that have been added
SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner, 0
FROM config.marc_subfield
- WHERE ARRAY[marc_format::TEXT, marc_record_type, tag, code] NOT IN (
- SELECT ARRAY[marc_format::TEXT, marc_record_type, tag, code]
+ WHERE ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code] NOT IN (
+ SELECT ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code]
FROM config.marc_subfield
WHERE owner IS NULL
)
mandatory, hidden, owner, depth
FROM ou_marc_subfields;
-CREATE OR REPLACE FUNCTION config.ou_marc_fields(marc_format INTEGER, marc_record_type TEXT, ou INTEGER) RETURNS SETOF config.marc_field AS $func$
+CREATE OR REPLACE FUNCTION config.ou_marc_fields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_field AS $func$
SELECT id, marc_format, marc_record_type, tag, name, description, fixed_field, repeatable, mandatory, hidden, owner
FROM (
SELECT id, marc_format, marc_record_type, tag, name, description,
AND not hidden;
$func$ LANGUAGE SQL;
-CREATE OR REPLACE FUNCTION config.ou_marc_subfields(marc_format INTEGER, marc_record_type TEXT, ou INTEGER) RETURNS SETOF config.marc_subfield AS $func$
+CREATE OR REPLACE FUNCTION config.ou_marc_subfields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_subfield AS $func$
SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner
FROM (
SELECT id, marc_format, marc_record_type, tag, code, description,