-- +migrate Up

CREATE TABLE `campaign_participants` (
    `id`          BIGINT PRIMARY KEY AUTO_INCREMENT,
    `campaign_id` BIGINT NOT NULL,
    `user_id`     BIGINT NOT NULL,
    `amount`      DECIMAL(15,2) NOT NULL,
    `created_at`  TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (`campaign_id`) 
        REFERENCES `campaigns`(`id`) 
        ON DELETE CASCADE,
    FOREIGN KEY (`user_id`) 
        REFERENCES `users`(`id`) 
        ON DELETE CASCADE,
    UNIQUE KEY `unique_campaign_user` (`campaign_id`, `user_id`)
);

-- +migrate Down
DROP TABLE `campaign_participants`;
