Files
cannaiq/backend/archive/setup-api-permissions-table.ts
Kelly d91c55a344 feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes)
- Add users management route
- Add frontend landing page and stale process monitor UI on /scraper-tools
- Move old development scripts to backend/archive/
- Update frontend build with new features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 04:07:31 -07:00

40 lines
1.0 KiB
TypeScript

import pg from 'pg';
const { Pool } = pg;
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
async function setupTable() {
try {
// Create the wp_dutchie_api_permissions table if it doesn't exist
await pool.query(`
CREATE TABLE IF NOT EXISTS wp_dutchie_api_permissions (
id SERIAL PRIMARY KEY,
user_name VARCHAR(255) NOT NULL,
api_key VARCHAR(255) NOT NULL UNIQUE,
allowed_ips TEXT,
allowed_domains TEXT,
is_active SMALLINT DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_used_at TIMESTAMP
)
`);
console.log('✅ Table wp_dutchie_api_permissions created or already exists');
// Check if table has any data
const result = await pool.query('SELECT COUNT(*) FROM wp_dutchie_api_permissions');
console.log(`✅ Table has ${result.rows[0].count} rows`);
await pool.end();
process.exit(0);
} catch (error) {
console.error('❌ Error setting up table:', error);
process.exit(1);
}
}
setupTable();