fix: remove non-deterministic CHECK constraint from templates table
- SQLite doesn't allow datetime('now') in CHECK constraints
- Drop tables before recreating to ensure clean schema
- 6-month filtering is already handled in application logic
- Successfully fetched and stored 199 templates
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
BIN
data/nodes.db
BIN
data/nodes.db
Binary file not shown.
@@ -39,10 +39,7 @@ CREATE TABLE IF NOT EXISTS templates (
|
||||
created_at DATETIME,
|
||||
updated_at DATETIME,
|
||||
url TEXT,
|
||||
scraped_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fresh_template CHECK (
|
||||
datetime(updated_at) >= datetime('now', '-6 months')
|
||||
)
|
||||
scraped_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Templates indexes
|
||||
|
||||
@@ -16,7 +16,16 @@ async function fetchTemplates() {
|
||||
// Initialize database
|
||||
const db = await createDatabaseAdapter('./data/nodes.db');
|
||||
|
||||
// Apply schema if needed
|
||||
// Drop existing templates table to ensure clean schema
|
||||
try {
|
||||
db.exec('DROP TABLE IF EXISTS templates');
|
||||
db.exec('DROP TABLE IF EXISTS templates_fts');
|
||||
console.log('🗑️ Dropped existing templates tables\n');
|
||||
} catch (error) {
|
||||
// Ignore errors if tables don't exist
|
||||
}
|
||||
|
||||
// Apply schema with updated constraint
|
||||
const schema = fs.readFileSync(path.join(__dirname, '../../src/database/schema.sql'), 'utf8');
|
||||
db.exec(schema);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user