final
This commit is contained in:
14
migrations/add_drop_description.sql
Normal file
14
migrations/add_drop_description.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
-- Migration to add description field to drops table
|
||||
-- Date: 2025-01-XX
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
-- Add description column to drops table
|
||||
ALTER TABLE `drops`
|
||||
ADD COLUMN `description` text DEFAULT NULL AFTER `item`;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
18
migrations/add_eur_referral_points.sql
Normal file
18
migrations/add_eur_referral_points.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- Migration to add EUR-based referral points settings
|
||||
-- This makes referral points universal across currencies by using EUR as the base
|
||||
-- Date: 2025-01-XX
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
-- Add EUR-based referral point settings
|
||||
INSERT INTO `referral_settings` (`setting_key`, `setting_value`, `description`) VALUES
|
||||
('points_per_eur', '10', 'Number of referral points earned per 1 EUR purchase by referred user'),
|
||||
('points_to_eur', '100', 'Number of referral points required to redeem 1 EUR discount')
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`description` = VALUES(`description`);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
30
migrations/add_multi_currency_prices.sql
Normal file
30
migrations/add_multi_currency_prices.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- Migration to add multi-currency pricing support for drops
|
||||
-- Date: 2025-01-XX
|
||||
-- Adds support for CHF and EUR prices, both regular and wholesale
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
-- Add price columns to drops table
|
||||
-- Prices are stored as decimal per gram
|
||||
ALTER TABLE `drops`
|
||||
ADD COLUMN `price_chf` decimal(10,4) DEFAULT NULL AFTER `ppu`,
|
||||
ADD COLUMN `price_eur` decimal(10,4) DEFAULT NULL AFTER `price_chf`,
|
||||
ADD COLUMN `wholesale_price_chf` decimal(10,4) DEFAULT NULL AFTER `price_eur`,
|
||||
ADD COLUMN `wholesale_price_eur` decimal(10,4) DEFAULT NULL AFTER `wholesale_price_chf`;
|
||||
|
||||
-- Migrate existing ppu data to new price fields
|
||||
-- ppu is stored as integer where 1000 = 1.00 EUR per gram
|
||||
-- Convert to decimal format and set both EUR and CHF prices
|
||||
UPDATE `drops`
|
||||
SET
|
||||
`price_eur` = `ppu` / 1000.0,
|
||||
`price_chf` = (`ppu` / 1000.0) * 0.97, -- Convert EUR to CHF (1 EUR ≈ 0.97 CHF)
|
||||
`wholesale_price_eur` = (`ppu` / 1000.0) * 0.76, -- 76% of regular price
|
||||
`wholesale_price_chf` = (`ppu` / 1000.0) * 0.76 * 0.97 -- 76% of regular price in CHF
|
||||
WHERE `ppu` IS NOT NULL AND `ppu` > 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user