21 lines
608 B
SQL
21 lines
608 B
SQL
-- Migration: Add harga_pokok to products and total_cost to sales
|
|
-- Run this in Supabase Dashboard > SQL Editor
|
|
|
|
-- Add harga_pokok column to products table
|
|
ALTER TABLE products
|
|
ADD COLUMN IF NOT EXISTS harga_pokok numeric DEFAULT 0;
|
|
|
|
-- Add total_cost column to sales table
|
|
ALTER TABLE sales
|
|
ADD COLUMN IF NOT EXISTS total_cost numeric DEFAULT 0;
|
|
|
|
-- Update existing products to have default harga_pokok if null
|
|
UPDATE products
|
|
SET harga_pokok = 0
|
|
WHERE harga_pokok IS NULL;
|
|
|
|
-- Update existing sales to have default total_cost if null
|
|
UPDATE sales
|
|
SET total_cost = 0
|
|
WHERE total_cost IS NULL;
|