-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
35 lines (30 loc) · 2.42 KB
/
schema.sql
File metadata and controls
35 lines (30 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- Card Stack Template Database Schema
-- This table stores card data for the CardStack component examples
-- Run this in your Neon database console to set up the schema
-- Drop table if exists (for clean reinstallation)
DROP TABLE IF EXISTS cards CASCADE;
-- Create cards table
CREATE TABLE cards (
id SERIAL PRIMARY KEY, -- Unique identifier for each card
title VARCHAR(255) NOT NULL, -- Card title (displayed at top)
description TEXT, -- Card content/description (displayed at bottom)
image_url TEXT NOT NULL, -- URL to card background image
display_order INTEGER NOT NULL DEFAULT 0, -- Order for displaying cards (lower = first)
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -- Timestamp when card was created
);
-- Create index on display_order for efficient sorting
CREATE INDEX idx_cards_display_order ON cards(display_order);
-- Seed data: Example cards with Unsplash images
-- Note: Only insert if table is empty to avoid duplicates on re-run
INSERT INTO cards (title, description, image_url, display_order)
SELECT * FROM (VALUES
('Mountain Vista', 'Breathtaking views from the highest peaks, where the air is crisp and the horizon endless.', 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=crop', 1),
('Ocean Waves', 'The rhythmic dance of waves meeting shore, a timeless symphony of nature.', 'https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800&h=600&fit=crop', 2),
('Forest Path', 'Wandering through ancient woods, where sunlight filters through emerald canopies.', 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800&h=600&fit=crop', 3),
('Desert Dunes', 'Golden sands sculpted by wind, creating an ever-changing landscape of beauty.', 'https://images.unsplash.com/photo-1509316785289-025f5b846b35?w=800&h=600&fit=crop', 4),
('City Lights', 'Urban brilliance illuminating the night, a testament to human achievement.', 'https://images.unsplash.com/photo-1514565131-fce0801e5785?w=800&h=600&fit=crop', 5),
('Northern Lights', 'Aurora borealis painting the sky with ethereal colours, nature''s greatest light show.', 'https://images.unsplash.com/photo-1531366936337-7c912a4589a7?w=800&h=600&fit=crop', 6)
) AS v(title, description, image_url, display_order)
WHERE NOT EXISTS (SELECT 1 FROM cards);
-- Query to verify data
-- SELECT * FROM cards ORDER BY display_order;