feat(db): add SQLx migrations and AppState with connection pool
- Add sqlx 0.8 (AnyPool, runtime-tokio, sqlite, postgres, migrate) - Create 6 migration files for both SQLite and PostgreSQL backends - Add server/db.rs: create_pool and run_migrations helpers - Add server/state.rs: AppState with LeptosOptions + AnyPool - Run migrations at server startup before accepting requests - Fix Port model: remove host_id (ports are now a global catalog) - Add HostPort join struct for the host_ports many-to-many table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
9
migrations/sqlite/0002_create_hosts.sql
Normal file
9
migrations/sqlite/0002_create_hosts.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- hosts: physical or virtual machines belonging to a network.
|
||||
-- The ip field must fall within the CIDR of the parent network
|
||||
-- (enforced in application code, not at the DB level).
|
||||
CREATE TABLE IF NOT EXISTS hosts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
ip TEXT NOT NULL,
|
||||
network_id INTEGER NOT NULL REFERENCES networks(id) ON DELETE CASCADE
|
||||
);
|
||||
Reference in New Issue
Block a user