feat(server): schéma PostgreSQL sync-ready (ticket #49)
Ajoute la migration initiale (migrations/0001_initial_schema.sql, incluant la table users nécessaire à l'adapter d'auth du ticket #48), le runner de migration (bin/migrate.dart) et l'accès Postgres (infrastructure/postgres/postgres_database.dart). dart pub get OK, dart analyze clean, dart test vert (le test PostgreSQL réel est skip faute de TEST_DATABASE_URL/Docker disponible dans ce sandbox ; SQL de migration revu manuellement). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
48
server/test/postgres_migrations_test.dart
Normal file
48
server/test/postgres_migrations_test.dart
Normal file
@ -0,0 +1,48 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:gametime_server/infrastructure/postgres/postgres_database.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('PostgreSQL migrations create the sync-ready schema', () async {
|
||||
final databaseUrl = Platform.environment['TEST_DATABASE_URL'];
|
||||
if (databaseUrl == null || databaseUrl.trim().isEmpty) {
|
||||
markTestSkipped(
|
||||
'Set TEST_DATABASE_URL to run PostgreSQL migration tests.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final connection = await PostgresConnectionFactory.fromDatabaseUrl(
|
||||
databaseUrl,
|
||||
).open();
|
||||
addTearDown(() => connection.close());
|
||||
|
||||
await PostgresMigrator(connection).applyMigrations();
|
||||
|
||||
final result = await connection.execute('''
|
||||
SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name IN (
|
||||
'users',
|
||||
'auth_sessions',
|
||||
'synced_resources',
|
||||
'shares',
|
||||
'share_recipients'
|
||||
)
|
||||
''');
|
||||
final tableNames = result.map((row) => row[0] as String).toSet();
|
||||
|
||||
expect(
|
||||
tableNames,
|
||||
containsAll({
|
||||
'users',
|
||||
'auth_sessions',
|
||||
'synced_resources',
|
||||
'shares',
|
||||
'share_recipients',
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user