refactor: implement database-specific schema architecture with schema-as-query pattern
🏗️ **Major Database Schema Refactoring** **Problem Solved**: Eliminated model duplication and multiple sources of truth by: - Removed duplicate models (`internal/models/content.go`) - Replaced inlined schema strings with sqlc-generated setup functions - Implemented database-specific schemas with proper NOT NULL constraints **Key Improvements**: ✅ **Single Source of Truth**: Database schemas define all types, no manual sync needed ✅ **Clean Generated Types**: sqlc generates `string` and `int64` instead of `sql.NullString/sql.NullTime` ✅ **Schema-as-Query Pattern**: Setup functions generated by sqlc for type safety ✅ **Database-Specific Optimization**: SQLite INTEGER timestamps, PostgreSQL BIGINT timestamps ✅ **Cross-Database Compatibility**: Single codebase supports both SQLite and PostgreSQL **Architecture Changes**: - `db/sqlite/` - SQLite-specific schema and setup queries - `db/postgresql/` - PostgreSQL-specific schema and setup queries - `db/queries/` - Cross-database CRUD queries using `sqlc.arg()` syntax - `internal/db/database.go` - Database abstraction with runtime selection - `internal/api/models.go` - Clean API models for requests/responses **Version Control System**: Complete element-level history with user attribution and rollback **Verification**: ✅ Full API workflow tested (create → update → rollback → versions) **Production Ready**: Supports SQLite (development) → PostgreSQL (production) migration
This commit is contained in:
33
test-ids.html
Normal file
33
test-ids.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test ID Generation</title>
|
||||
<script src="demo-site/insertr.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<section class="hero">
|
||||
<h1 class="insertr">Transform Your Business with Expert Consulting</h1>
|
||||
<p class="lead insertr">We help small businesses grow through strategic planning, process optimization, and digital transformation. Our team brings 15+ years of experience to drive your success.</p>
|
||||
<a href="contact.html" class="btn-primary insertr">Get Started Today</a>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const core = new InsertrCore();
|
||||
const elements = core.findEnhancedElements();
|
||||
|
||||
console.log('Testing ID generation:');
|
||||
elements.forEach(element => {
|
||||
const metadata = core.getElementMetadata(element);
|
||||
console.log(`${element.tagName.toLowerCase()}: "${element.textContent.trim()}" => ${metadata.contentId}`);
|
||||
});
|
||||
|
||||
// Expected IDs from CLI:
|
||||
console.log('\nExpected from CLI:');
|
||||
console.log('h1: hero-title-7cfeea');
|
||||
console.log('p: hero-lead-e47475');
|
||||
console.log('a: hero-link-76c620');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user