-- Import with verification (M502 #5522): a finished download is checked -- against the album it was grabbed for before anything reaches the library. -- -- grabs (columns) how far the download has got, and what the import -- made of it: the verdict, its reason and evidence, -- where the files went. -- grabs.end_reason a grab also ends by being imported, refused, or -- found to be an album already held. -- release_blocks.reason import: the files were not the album. -- acquisition_settings which library folder new music is filed into -- ('' = the first scan path). ALTER TABLE grabs ADD COLUMN progress real NOT NULL DEFAULT 0, ADD COLUMN import_state text NOT NULL DEFAULT '' CONSTRAINT grabs_import_state_check CHECK (import_state IN ('', 'downloading', 'waiting', 'importing', 'imported', 'refused', 'review', 'held', 'failed')), ADD COLUMN import_reason text NOT NULL DEFAULT '', ADD COLUMN import_detail jsonb NOT NULL DEFAULT '{}', -- A person said "import anyway" to a download the check held for them. ADD COLUMN import_forced boolean NOT NULL DEFAULT false, ADD COLUMN import_attempts integer NOT NULL DEFAULT 0, ADD COLUMN import_updated_at timestamptz, ADD COLUMN imported_at timestamptz, ADD COLUMN imported_files integer NOT NULL DEFAULT 0, ADD COLUMN destination text NOT NULL DEFAULT ''; ALTER TABLE grabs DROP CONSTRAINT grabs_end_reason_check; ALTER TABLE grabs ADD CONSTRAINT grabs_end_reason_check CHECK (end_reason IN ('', 'superseded', 'imported', 'refused', 'held')); CREATE INDEX grabs_live_idx ON grabs (grabbed_at) WHERE ended_at IS NULL; ALTER TABLE release_blocks DROP CONSTRAINT release_blocks_reason_check; ALTER TABLE release_blocks ADD CONSTRAINT release_blocks_reason_check CHECK (reason IN ('operator', 'files', 'import')); ALTER TABLE acquisition_settings ADD COLUMN import_root text NOT NULL DEFAULT '';