This commit is contained in:
root
2026-01-03 06:06:54 +00:00
parent d138dae2ca
commit eeaa9a66bb
16 changed files with 728 additions and 348 deletions

View 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;

View 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;

View 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;