CREATE TABLE user_agreements
(
    id SERIAL PRIMARY KEY,
    version VARCHAR(20) NOT NULL,
    content TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE user_agreement_acceptance
(
    id SERIAL PRIMARY KEY,
    user_id INT NOT NULL UNIQUE,
    agreement_id INT NOT NULL UNIQUE,
    accepted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

ALTER TABLE "user_agreement_acceptance" ADD FOREIGN KEY ("user_id") REFERENCES "users" ("id");
ALTER TABLE "user_agreement_acceptance" ADD FOREIGN KEY ("agreement_id") REFERENCES "user_agreements" ("id");

