feat: implement daily character guessing game with local storage and hint system
- Added character selection and history management using local storage. - Implemented hint system that unlocks based on the number of guesses. - Enhanced UI with animations for hint unlocks and special win conditions. - Created a server endpoint to record wins in the database.
This commit is contained in:
64
scripts/init-column-config.ts
Normal file
64
scripts/init-column-config.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Initialize config table with column visibility settings for characterHistory table
|
||||
*/
|
||||
|
||||
import { createClient } from '@libsql/client';
|
||||
import { drizzle } from 'drizzle-orm/libsql';
|
||||
import { config } from '../src/lib/server/db/schema';
|
||||
import { like } from 'drizzle-orm';
|
||||
|
||||
// Load environment variables
|
||||
const DATABASE_URL = process.env.DATABASE_URL || 'file:local.db';
|
||||
|
||||
const client = createClient({ url: DATABASE_URL });
|
||||
const db = drizzle(client);
|
||||
|
||||
// Define the columns in characterHistory table
|
||||
const columns = [
|
||||
'gender',
|
||||
'affiliations',
|
||||
'haki',
|
||||
'bounty',
|
||||
'height',
|
||||
'origin',
|
||||
'devilFruitType',
|
||||
'arc',
|
||||
'status'
|
||||
] as const;
|
||||
|
||||
async function initColumnConfig(): Promise<void> {
|
||||
try {
|
||||
console.log('Initializing column visibility config...\n');
|
||||
|
||||
for (const column of columns) {
|
||||
const key = `characterHistory.column.${column}.visible`;
|
||||
const value = 'true';
|
||||
|
||||
await db.insert(config)
|
||||
.values({ key, value })
|
||||
.onConflictDoNothing();
|
||||
|
||||
console.log(`✓ Added config key: ${key} = ${value}`);
|
||||
}
|
||||
|
||||
console.log('\n✓ Successfully initialized column visibility config');
|
||||
|
||||
// Display all config entries
|
||||
const allConfig = await db.select()
|
||||
.from(config)
|
||||
.where(like(config.key, 'characterHistory.column.%.visible'));
|
||||
|
||||
console.log('\nCurrent column visibility config:');
|
||||
allConfig.forEach(row => {
|
||||
console.log(` ${row.key}: ${row.value}`);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error initializing config:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
initColumnConfig();
|
||||
Reference in New Issue
Block a user