27 lines
964 B
SQL
27 lines
964 B
SQL
-- +goose Up
|
|
-- +goose StatementBegin
|
|
-- Shared, write-once lookup of classifications. A row is reused only when
|
|
-- every content column matches; any difference (e.g. a changed description)
|
|
-- creates a new row.
|
|
--
|
|
-- When adding a new scheme flag column (e.g. "is_unspsc"), the same migration
|
|
-- must drop and recreate "classification_codes_content" with the new column
|
|
-- included, otherwise rows differing only by that flag would be merged.
|
|
CREATE TABLE IF NOT EXISTS "classification_codes" (
|
|
"id" INTEGER PRIMARY KEY,
|
|
"is_cpv" BOOLEAN NOT NULL,
|
|
"code" TEXT NOT NULL,
|
|
"classification" TEXT NOT NULL
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "classification_codes_content"
|
|
ON "classification_codes" ("is_cpv", "code", "classification");
|
|
CREATE INDEX IF NOT EXISTS "classification_codes_code"
|
|
ON "classification_codes" ("code");
|
|
-- +goose StatementEnd
|
|
|
|
-- +goose Down
|
|
-- +goose StatementBegin
|
|
DROP TABLE IF EXISTS "classification_codes";
|
|
-- +goose StatementEnd
|