SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TYPE public.quest_status AS ENUM ('pending', 'in_progress', 'success', 'failed'); CREATE TABLE public.quests ( id SERIAL PRIMARY KEY, provider_id VARCHAR(64) NOT NULL, quest_id INTEGER NOT NULL, tg_id BIGINT NOT NULL, status quest_status NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP ); CREATE OR REPLACE FUNCTION update_updated_at_column() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = NOW(); RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER update_quests_updated_at BEFORE UPDATE ON public.quests FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column(); DROP TRIGGER IF EXISTS update_quests_updated_at ON public.quests; DROP FUNCTION IF EXISTS update_updated_at_column; DROP TABLE IF EXISTS public.quests; DROP TYPE IF EXISTS public.quest_status;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear