From 181f967bd005d3d65c2174f09beb8e3b48d6872f Mon Sep 17 00:00:00 2001 From: DaX Date: Mon, 30 Jun 2025 22:42:33 +0200 Subject: [PATCH] Add migration for specific PLA Basic colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added 30 specific PLA Basic colors with correct hex codes - Each color has 1 refill AND 1 spool (total quantity: 2) - Price set to 3499/3999 RSD format - All other filaments zeroed out (won't show in table) - Created migration script and deployment helper 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../migrations/013_add_pla_basic_colors.sql | 95 +++++++++++++++++++ scripts/add-pla-basic-colors.sh | 51 ++++++++++ 2 files changed, 146 insertions(+) create mode 100644 database/migrations/013_add_pla_basic_colors.sql create mode 100755 scripts/add-pla-basic-colors.sh diff --git a/database/migrations/013_add_pla_basic_colors.sql b/database/migrations/013_add_pla_basic_colors.sql new file mode 100644 index 0000000..c61e319 --- /dev/null +++ b/database/migrations/013_add_pla_basic_colors.sql @@ -0,0 +1,95 @@ +-- Migration: Add specific PLA Basic colors +-- This migration adds the specific set of colors for PLA Basic filaments + +-- First, let's add any missing colors to the colors table +INSERT INTO colors (name, hex) VALUES + ('Jade White', '#FFFFFF'), + ('Beige', '#F7E6DE'), + ('Light Gray', '#D0D2D4'), + ('Yellow', '#F4EE2A'), + ('Sunflower Yellow', '#FEC601'), + ('Pumpkin Orange', '#FF8E16'), + ('Orange', '#FF6A13'), + ('Gold', '#E4BD68'), + ('Bright Green', '#BDCF00'), + ('Bambu Green', '#16C344'), + ('Mistletoe Green', '#3F8E43'), + ('Pink', '#F55A74'), + ('Hot Pink', '#F5547D'), + ('Magenta', '#EC008C'), + ('Red', '#C12E1F'), + ('Maroon Red', '#832140'), + ('Purple', '#5E43B7'), + ('Indigo Purple', '#482A60'), + ('Turquoise', '#00B1B7'), + ('Cyan', '#0086D6'), + ('Cobalt Blue', '#0055B8'), + ('Blue', '#0A2989'), + ('Brown', '#9D432C'), + ('Cocoa Brown', '#6F5034'), + ('Bronze', '#847D48'), + ('Gray', '#8E9089'), + ('Silver', '#A6A9AA'), + ('Blue Grey', '#5B6579'), + ('Dark Gray', '#555555'), + ('Black', '#000000') +ON CONFLICT (name) +DO UPDATE SET hex = EXCLUDED.hex; + +-- Now add PLA Basic filaments for each of these colors +-- We'll add them with 1 refill and 1 spool each +INSERT INTO filaments (tip, finish, boja, boja_hex, refill, spulna, kolicina, cena) +SELECT + 'PLA' as tip, + 'Basic' as finish, + c.name as boja, + c.hex as boja_hex, + 1 as refill, + 1 as spulna, + 2 as kolicina, + '3499/3999' as cena +FROM colors c +WHERE c.name IN ( + 'Jade White', 'Beige', 'Light Gray', 'Yellow', 'Sunflower Yellow', + 'Pumpkin Orange', 'Orange', 'Gold', 'Bright Green', 'Bambu Green', + 'Mistletoe Green', 'Pink', 'Hot Pink', 'Magenta', 'Red', + 'Maroon Red', 'Purple', 'Indigo Purple', 'Turquoise', 'Cyan', + 'Cobalt Blue', 'Blue', 'Brown', 'Cocoa Brown', 'Bronze', + 'Gray', 'Silver', 'Blue Grey', 'Dark Gray', 'Black' +) +AND NOT EXISTS ( + SELECT 1 FROM filaments f + WHERE f.tip = 'PLA' + AND f.finish = 'Basic' + AND f.boja = c.name +); + +-- Update any existing PLA Basic filaments to ensure they have correct inventory +UPDATE filaments +SET refill = 1, spulna = 1, kolicina = 2, cena = '3499/3999' +WHERE tip = 'PLA' +AND finish = 'Basic' +AND boja IN ( + 'Jade White', 'Beige', 'Light Gray', 'Yellow', 'Sunflower Yellow', + 'Pumpkin Orange', 'Orange', 'Gold', 'Bright Green', 'Bambu Green', + 'Mistletoe Green', 'Pink', 'Hot Pink', 'Magenta', 'Red', + 'Maroon Red', 'Purple', 'Indigo Purple', 'Turquoise', 'Cyan', + 'Cobalt Blue', 'Blue', 'Brown', 'Cocoa Brown', 'Bronze', + 'Gray', 'Silver', 'Blue Grey', 'Dark Gray', 'Black' +); + +-- Zero out ALL other filaments (not PLA Basic with these specific colors) +UPDATE filaments +SET refill = 0, spulna = 0, kolicina = 0 +WHERE NOT ( + tip = 'PLA' + AND finish = 'Basic' + AND boja IN ( + 'Jade White', 'Beige', 'Light Gray', 'Yellow', 'Sunflower Yellow', + 'Pumpkin Orange', 'Orange', 'Gold', 'Bright Green', 'Bambu Green', + 'Mistletoe Green', 'Pink', 'Hot Pink', 'Magenta', 'Red', + 'Maroon Red', 'Purple', 'Indigo Purple', 'Turquoise', 'Cyan', + 'Cobalt Blue', 'Blue', 'Brown', 'Cocoa Brown', 'Bronze', + 'Gray', 'Silver', 'Blue Grey', 'Dark Gray', 'Black' + ) +); \ No newline at end of file diff --git a/scripts/add-pla-basic-colors.sh b/scripts/add-pla-basic-colors.sh new file mode 100755 index 0000000..2001912 --- /dev/null +++ b/scripts/add-pla-basic-colors.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Script to add specific PLA Basic colors to production database + +echo "🎨 Adding PLA Basic colors to production database..." + +# Get the RDS endpoint from terraform output +DB_HOST=$(cat terraform-outputs.json | grep -A1 "rds_endpoint" | grep "value" | cut -d'"' -f4 | cut -d':' -f1) + +if [ -z "$DB_HOST" ]; then + echo "❌ Could not find RDS endpoint in terraform-outputs.json" + exit 1 +fi + +echo "📍 Database host: $DB_HOST" + +# Execute the migration +echo "🚀 Running migration..." +aws ssm send-command \ + --document-name "AWS-RunShellScript" \ + --targets "Key=tag:Name,Values=filamenteka-api-instance" \ + --parameters commands="[\"PGPASSWORD=\$DB_PASSWORD psql -h $DB_HOST -U filamenteka -d filamenteka -f /tmp/add_pla_colors.sql\"]" \ + --region eu-central-1 \ + --query "Command.CommandId" \ + --output text > /tmp/command-id.txt + +COMMAND_ID=$(cat /tmp/command-id.txt) +echo "⏳ Command ID: $COMMAND_ID" + +# Wait for command to complete +echo "⏳ Waiting for migration to complete..." +sleep 5 + +# Check command status +aws ssm get-command-invocation \ + --command-id "$COMMAND_ID" \ + --instance-id $(aws ec2 describe-instances --filters "Name=tag:Name,Values=filamenteka-api-instance" --query "Reservations[0].Instances[0].InstanceId" --output text --region eu-central-1) \ + --region eu-central-1 \ + --query "Status" \ + --output text + +echo "✅ Migration completed!" +echo "" +echo "📝 Summary of changes:" +echo "- Added 30 specific PLA Basic colors" +echo "- Each color has 1 refill AND 1 spool (total quantity: 2)" +echo "- Price set to 3499/3999 RSD" +echo "- Zeroed out ALL other filaments (they won't show in the table)" + +# Cleanup +rm -f /tmp/command-id.txt \ No newline at end of file