-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
61 lines (56 loc) · 2.22 KB
/
schema.sql
File metadata and controls
61 lines (56 loc) · 2.22 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- HTMLShare Astro - Cloudflare D1 Database Schema
-- Migration from Supabase to D1
-- Pages table - core HTML content storage with compression support
CREATE TABLE IF NOT EXISTS pages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
url_id TEXT UNIQUE NOT NULL,
title TEXT NOT NULL DEFAULT 'Shared HTML',
content TEXT NOT NULL,
language TEXT DEFAULT 'html',
description TEXT,
view_count INTEGER DEFAULT 0,
is_public BOOLEAN DEFAULT 1,
is_compressed BOOLEAN DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- Optional: Users table (simplified version for future extension)
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
email TEXT UNIQUE,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- Optional: Tags table for content categorization
CREATE TABLE IF NOT EXISTS tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page_id INTEGER,
tag_name TEXT NOT NULL,
FOREIGN KEY (page_id) REFERENCES pages (id) ON DELETE CASCADE
);
-- Indexes for performance
CREATE INDEX IF NOT EXISTS idx_pages_url_id ON pages(url_id);
CREATE INDEX IF NOT EXISTS idx_pages_created_at ON pages(created_at);
CREATE INDEX IF NOT EXISTS idx_pages_public ON pages(is_public);
CREATE INDEX IF NOT EXISTS idx_tags_page_id ON tags(page_id);
-- Insert some demo data
INSERT OR IGNORE INTO pages (url_id, title, content, language, description) VALUES
('demo-card', 'Card Demo', '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Card Demo</title>
<style>
body { font-family: Arial, sans-serif; background: #f5f5f5; padding: 20px; }
.card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); max-width: 400px; margin: 20px auto; }
.card h2 { color: #333; margin-top: 0; }
.card p { color: #666; line-height: 1.6; }
</style>
</head>
<body>
<div class="card">
<h2>Welcome to HTMLShare</h2>
<p>This is a demo card showing how HTML content is rendered directly without iframe.</p>
<p>You can now use <code>class="card"</code> and it will work perfectly!</p>
</div>
</body>
</html>', 'html', 'Demonstrates card CSS class support');