ALTER TABLE qt_pricelists
	ADD COLUMN IF NOT EXISTS source ENUM('estimate', 'warehouse', 'competitor') NOT NULL DEFAULT 'estimate' AFTER id;

UPDATE qt_pricelists
SET source = 'estimate'
WHERE source IS NULL OR source = '';

ALTER TABLE qt_pricelists
	DROP INDEX IF EXISTS idx_qt_pricelists_version;

CREATE UNIQUE INDEX idx_qt_pricelists_source_version
	ON qt_pricelists(source, version);

CREATE INDEX idx_qt_pricelists_source_created_at
	ON qt_pricelists(source, created_at);
