← back to Grassclothwallpaper
execute-sql-setup.js
31 lines
require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const supabaseUrl = process.env.SUPABASE_URL || 'https://fypvpcxyfmmdhtklgbrt.supabase.co';
const supabaseServiceKey = process.env.SUPABASE_SERVICE_KEY || process.env.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZ5cHZwY3h5Zm1tZGh0a2xnYnJ0Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTg4MTAxMjMsImV4cCI6MjA3NDM4NjEyM30.fzDf6VE7jyrqLIbebAwI1NHXi50pI0b_FgQVO-6QcAk';
console.log('📝 Instructions to add has_valid_image column:\n');
console.log('1. Go to your Supabase dashboard: https://supabase.com/dashboard');
console.log('2. Select your project (fypvpcxyfmmdhtklgbrt)');
console.log('3. Navigate to the SQL Editor');
console.log('4. Copy and run this SQL:\n');
const sql = `-- Add has_valid_image column to grasscloth_products table
ALTER TABLE grasscloth_products
ADD COLUMN IF NOT EXISTS has_valid_image BOOLEAN DEFAULT false;
-- Create index for better performance
CREATE INDEX IF NOT EXISTS idx_grasscloth_products_has_valid_image
ON grasscloth_products(has_valid_image);
-- Add comment to document the column
COMMENT ON COLUMN grasscloth_products.has_valid_image IS 'Indicates whether the product has a valid, accessible image URL';`;
console.log('```sql');
console.log(sql);
console.log('```\n');
console.log('5. After running the SQL, run: node setup-image-validation.js');
console.log('6. Then test the site to see only products with valid images\n');
console.log('📌 Alternative: The site will still work without this column!');
console.log(' It will fallback to filtering by image_url field automatically.');