41 lines
1.4 KiB
SQL
41 lines
1.4 KiB
SQL
-- +goose Up
|
|
-- +goose StatementBegin
|
|
CREATE TABLE IF NOT EXISTS "opportunities" (
|
|
-- Surrogate key. "uuid" is the real identifier; "id" exists only to give
|
|
-- the title search index (opportunities_fts) a stable rowid to point at.
|
|
"id" INTEGER PRIMARY KEY,
|
|
"uuid" TEXT NOT NULL UNIQUE,
|
|
"uuid_type" TEXT NOT NULL,
|
|
"title" TEXT NOT NULL,
|
|
"status" TEXT NOT NULL,
|
|
"description" TEXT NOT NULL DEFAULT '',
|
|
"buyer_name" TEXT NOT NULL DEFAULT '',
|
|
-- classifications: see tender_classifications
|
|
"buyer_id" TEXT NOT NULL DEFAULT '',
|
|
"main_category" TEXT NOT NULL DEFAULT '',
|
|
"procurement_method" TEXT NOT NULL DEFAULT '',
|
|
"multi_lot" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
"sme_suitable" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
"vcse_suitable" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
"start_date" DATETIME,
|
|
"end_date" DATETIME,
|
|
"gross_value" REAL NOT NULL DEFAULT 0,
|
|
"has_documents" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
"source" TEXT NOT NULL DEFAULT '',
|
|
-- Release date of the newest release applied to this row. A release
|
|
-- older than this never overwrites the tender.
|
|
"latest_release_date" DATETIME NOT NULL
|
|
-- releases: see tender_ocds_releases
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "opportunities_status"
|
|
ON "opportunities" ("status");
|
|
CREATE INDEX IF NOT EXISTS "opportunities_latest_release_date"
|
|
ON "opportunities" ("latest_release_date");
|
|
-- +goose StatementEnd
|
|
|
|
-- +goose Down
|
|
-- +goose StatementBegin
|
|
DROP TABLE IF EXISTS "opportunities";
|
|
-- +goose StatementEnd
|