-- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- 
-- DROP TABLE IF EXISTS contacts CASCADE;
-- DROP TABLE IF EXISTS messages CASCADE;
-- DROP TABLE IF EXISTS scheduled_messages CASCADE;
-- DROP TABLE IF EXISTS scheduled_message_events CASCADE;
-- DROP TABLE IF EXISTS message_event_responses CASCADE;
-- 
-- CREATE TABLE IF NOT EXISTS contacts (
--     id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
--     phone_number TEXT NOT NULL,
--     user_id UUID NOT NULL,
--     first_name TEXT NULL,
--     last_name TEXT NULL,
--     nickname TEXT NULL
-- );
-- 
-- CREATE TABLE IF NOT EXISTS messages (
--     id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
--     content TEXT NOT NULL,
--     user_id UUID NOT NULL
-- );
-- 
-- CREATE TABLE IF NOT EXISTS scheduled_messages (
--     id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
--     scheduled timestamptz NOT NULL,
--     created timestamptz DEFAULT now(),
--     status TEXT CHECK (status IN ('PENDING', 'READY', 'PROCESSING', 'DONE')),
--     user_id UUID NOT NULL
-- );
-- 
-- CREATE TABLE IF NOT EXISTS scheduled_message_events (
--     id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
--     contact_id UUID NOT NULL,
--     message_id UUID NOT NULL,
--     scheduled_message_id UUID NOT NULL,
--     created timestamptz DEFAULT now()
-- );
-- 
-- CREATE TABLE IF NOT EXISTS message_event_responses (
--     id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
--     scheduled_message_event_id UUID NULL,
--     response JSONB NOT NULL,
--     user_id UUID NOT NULL,
--     sent timestamptz NOT NULL,
--     contact_id UUID NULL,
--     message_id UUID NULL,
--     status TEXT CHECK (status IN ('INSTANT', 'SCHEDULED'))
-- );
