CREATE TABLE IF NOT EXISTS survey_mcaptcha_hostname (
	url VARCHAR(3000) UNIQUE NOT NULL,
	secret VARCHAR(100) UNIQUE NOT NULL,
	ID SERIAL PRIMARY KEY NOT NULL
);

CREATE TABLE IF NOT EXISTS survey_mcaptcha_campaign (
	campaign_id VARCHAR(100) NOT NULL,
	public_id VARCHAR(100) NOT NULL,
	url_id INTEGER NOT NULL references survey_mcaptcha_hostname(ID) ON DELETE CASCADE,
	synced_till INTEGER NOT NULL DEFAULT 0,
	ID SERIAL PRIMARY KEY NOT NULL
);


CREATE TABLE IF NOT EXISTS survey_mcaptcha_analytics (
	campaign_id INTEGER references survey_mcaptcha_campaign(ID)  ON DELETE CASCADE,
	time INTEGER NOT NULL,
	difficulty_factor INTEGER NOT NULL,
	worker_type VARCHAR(100) NOT NULL,
	ID SERIAL PRIMARY KEY NOT NULL
);
