-- Catalogue objects (the inventory-minimum core). One row = one object or a group. CREATE TABLE object ( id UUID PRIMARY KEY, object_number TEXT NOT NULL UNIQUE CHECK (object_number <> ''), object_name TEXT NOT NULL CHECK (object_name <> ''), number_of_objects INTEGER NOT NULL DEFAULT 1 CHECK (number_of_objects >= 1), brief_description TEXT CHECK (brief_description <> ''), current_location TEXT CHECK (current_location <> ''), current_owner TEXT CHECK (current_owner <> ''), recorder TEXT CHECK (recorder <> ''), recording_date DATE, visibility TEXT NOT NULL DEFAULT 'draft' CHECK (visibility IN ('draft', 'internal', 'public')), -- updated_at is maintained by the repository (set to now() on update). created_at TIMESTAMPTZ NOT NULL DEFAULT now(), updated_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX object_visibility_idx ON object (visibility);