1/**
2 * Database query functions for productpanel
3 * Provides typed functions for database operations
4 */
5
36
37/**
38 * Create a new app in the database
39 */
40export async function createApp(app: Omit<App, 'id' | 'created_at'>): Promise<App> {
1/**
2 * Fix Apps Data Structure
3 * Repairs any apps with incorrect data structure in the database
4 */
5
122 };
123
124 // Update the app in the database
125 await sqlite.execute({
126 sql: `UPDATE apps SET
222 };
223
224 // Update the feedback in the database
225 await sqlite.execute({
226 sql: `UPDATE feedback SET
109 const feedback = generateRandomFeedback(appId);
110
111 // Insert feedback into database with named parameters
112 // No need to specify ID as it's auto-incremented
113 await sqlite.execute({
49- All test data can be easily identified by the "[TEST]" prefix
50- The cleanup function removes only data with the test prefix
51- Test data is entirely contained within Val Town's SQLite database
52
74 <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4">
75 <p class="text-yellow-700">
76 <strong>Note:</strong> These actions directly affect the database. Use with caution.
77 </p>
78 </div>
5import { runMigrations } from "../db/migrations.ts";
6
7// Step 1: Initialize the database
8console.log("Initializing database...");
9const migrationResult = await runMigrations();
10if (!migrationResult.success) {
11 console.error("Database migration failed:", migrationResult.error);
12 Deno.exit(1);
13}
14console.log("Database initialized successfully");
15
16// Step 2: Create test data
1/**
2 * Initialize the database and create a test app
3 * Run this script to set up the initial database for local testing
4 */
5
6import { initializeDatabase } from "../db/init.ts";
7import { createApp } from "../db/queries.ts";
8import { generateApiKey } from "../utils/apiKey.ts";
9
10async function main() {
11 console.log("Initializing database...");
12 const initResult = await initializeDatabase();
13
14 if (!initResult.success) {
15 console.error("Failed to initialize database:", initResult.error);
16 return;
17 }
18
19 console.log("Database initialized successfully");
20
21 // Create a test app
25
26 try {
27 // Get all apps from the database
28 const apps = await getAllApps();
29
44 }
45
46 // Delete the app from the database
47 const deleted = await deleteApp(appId);
48
39 const apiKey = generateApiKey();
40
41 // Create the app in the database
42 const app = await createApp({
43 name: validation.data.name!,