2017-07-09 16:53:35 +00:00
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:postgres/postgres.dart';
|
|
|
|
|
2017-08-01 05:45:54 +00:00
|
|
|
Future<PostgreSQLConnection> connectToPostgres(Iterable<String> schemas) async {
|
2017-07-09 16:53:35 +00:00
|
|
|
var conn = new PostgreSQLConnection('127.0.0.1', 5432, 'angel_orm_test',
|
|
|
|
username: Platform.environment['POSTGRES_USERNAME'] ?? 'postgres',
|
|
|
|
password: Platform.environment['POSTGRES_PASSWORD'] ?? 'password');
|
|
|
|
await conn.open();
|
|
|
|
|
2017-08-01 05:45:54 +00:00
|
|
|
for (var s in schemas)
|
|
|
|
await conn
|
|
|
|
.execute(await new File('test/models/$s.up.g.sql').readAsString());
|
2017-07-09 16:53:35 +00:00
|
|
|
|
|
|
|
return conn;
|
|
|
|
}
|