Commit ddac136f authored by thejoelinux's avatar thejoelinux

ajout script SQL

parent 32d3e9cc
DROP TABLE IF EXISTS lud_payments;
CREATE TABLE `lud_payments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subscription_id` int(11) NOT NULL,
`payment_method_id` int(11) NOT NULL,
`amount` float(5,2) NOT NULL DEFAULT '0.00',
`comments` text NOT NULL,
`check_bank_name` varchar(64) NULL,
`check_owner_name` varchar(64) NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `subscription_id` (`subscription_id`),
KEY `payment_method_id` (`payment_method_id`),
CONSTRAINT `lud_payments_ibfk_1` FOREIGN KEY (`subscription_id`) REFERENCES `lud_subscriptions` (`id`),
CONSTRAINT `lud_payments_ibfk_2` FOREIGN KEY (`payment_method_id`) REFERENCES `lud_payment_methods` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO lud_payments (subscription_id, payment_method_id, amount, comments, created_at)
SELECT id, payment_method_id, price,
CASE WHEN comments IS NULL THEN
'(Importé automatiquement)'
ELSE
CONCAT('(Importé automatiquement) ', comments)
END AS comments, now()
FROM `lud_subscriptions`;
-- backup lud_subscriptions
CREATE TABLE lud_subscriptions_bck AS SELECT * FROM lud_subscriptions;
-- rename some columns as deprecated
ALTER TABLE `lud_subscriptions` DROP FOREIGN KEY `fk_member_sub_payment_method_id`;
ALTER TABLE `lud_subscriptions` CHANGE `payment_method_id` `payment_method_id_bck` INT(11) NOT NULL;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment