16 lines
660 B
SQL
16 lines
660 B
SQL
-- Drop the now-obsolete subscriptions table
|
|
DROP TABLE IF EXISTS `subscriptions`;
|
|
|
|
-- Create a table to log credit purchases
|
|
CREATE TABLE IF NOT EXISTS `purchases` (
|
|
`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
`user_id` INT(11) UNSIGNED NOT NULL,
|
|
`plan_id` INT NOT NULL,
|
|
`stripe_charge_id` VARCHAR(255) NOT NULL,
|
|
`credits_purchased` INT(11) NOT NULL,
|
|
`amount_paid` DECIMAL(10, 2) NOT NULL,
|
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
|
|
FOREIGN KEY (`plan_id`) REFERENCES `plans`(`id`) ON DELETE RESTRICT
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|