From ea528abc3d45f3ceea96e0c440cf117b2d872138 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 6 Jan 2024 18:33:09 +0800 Subject: [PATCH 1/7] Updated to postgres 3 --- .vscode/settings.json | 4 +- logo_icon_512.jpg | Bin 0 -> 23116 bytes packages/orm/angel_orm_postgres/CHANGELOG.md | 6 +- .../orm/angel_orm_postgres/example/main.dart | 1 - .../lib/src/orm_postgres.dart | 193 +++++------------- packages/orm/angel_orm_postgres/pubspec.yaml | 6 +- .../orm/angel_orm_postgres/test/common.dart | 15 +- 7 files changed, 63 insertions(+), 162 deletions(-) create mode 100644 logo_icon_512.jpg diff --git a/.vscode/settings.json b/.vscode/settings.json index 4e5534bc..5934a199 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,7 +12,7 @@ "js": [] }, "editor.codeActionsOnSave": { - "source.fixAll.markdownlint": true - }, + "source.fixAll.markdownlint": "explicit" + }, "cmake.configureOnOpen": false } \ No newline at end of file diff --git a/logo_icon_512.jpg b/logo_icon_512.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3dc373e86496f98c9082ba5a4e5f82dc93057fd5 GIT binary patch literal 23116 zcmeFZc|4T=zc)UjMD`^irYsSm>>`t74@vfz3fV%kGiF36+Z5r0qO2h%S+mU8g(Q2{ z8KdmW4B=uH_tp1&&wbAMKEC&T&bfcT-#@>{eVO;n#awgE`}KZp&)4#H_~VcO;WE}Y z(uXiGFhK5tKaj&Yh^=0T#{&q&)D$8Efk2K!m>4cWj(}&};Lx_&%L$g_$61dvGqbX@vYucA4`vn)PIfkqKj(jL^5^4!J_SD5jx!(sbH#t} zIBbD%A3p-p#K<59Il|4r$jxxr0fB;)90k|m&rGww1Mwt)0EIi|Ye7cMnhhfWV;OkkGK`r!lc{ z&z{Gpq`pc^&-g1dD=)vGu&DTbN$IDm>YCcR`p*q*?H!$6-CufohlWQ+$Hsq5OwJMK zfBsrnTv}csZ*BkH+1&&75B|`_0Mhxd$G;Hv4|H*ZbR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z0;8RhM zDDOGrMQLd}7_yPy*4x8+bP-wK0+O?O-U|;O1ilE&Gm-u$p2pT#ij6KE@g*&~KW@*v zFIIK^ybs??Ajc)vYl(&$)}A7*gVpH-N&3ePW6XWEWeM{mx~rZsQOF?pr0Ia5SCQ62 z>@)@w?roAgjvR(x4zJhikB4@*9eB5A?5xE3vh`N?Shzi}R(Q6@%!T}SgZaI||Nr{` KO?<>Y_x%-4zVa;q literal 0 HcmV?d00001 diff --git a/packages/orm/angel_orm_postgres/CHANGELOG.md b/packages/orm/angel_orm_postgres/CHANGELOG.md index 9adb0f70..1fe2b716 100644 --- a/packages/orm/angel_orm_postgres/CHANGELOG.md +++ b/packages/orm/angel_orm_postgres/CHANGELOG.md @@ -1,11 +1,9 @@ # Change Log -## 8.1.1 - -* Updated repository link - ## 8.1.0 +* Updated repository links +* Updated `postgres` to 3.0.0 * Updated `lints` to 3.0.0 * Fixed linter warnings diff --git a/packages/orm/angel_orm_postgres/example/main.dart b/packages/orm/angel_orm_postgres/example/main.dart index 039d097a..1dcf0be8 100644 --- a/packages/orm/angel_orm_postgres/example/main.dart +++ b/packages/orm/angel_orm_postgres/example/main.dart @@ -1,6 +1,5 @@ import 'dart:io'; import 'package:angel3_orm_postgres/angel3_orm_postgres.dart'; -import 'package:postgres_pool/postgres_pool.dart'; void main() async { var executor = PostgreSqlPoolExecutor(PgPool( diff --git a/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart b/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart index f84e0345..24b30f4a 100644 --- a/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart +++ b/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart @@ -2,40 +2,46 @@ import 'dart:async'; import 'dart:convert'; import 'package:angel3_orm/angel3_orm.dart'; import 'package:logging/logging.dart'; -import 'package:pool/pool.dart'; import 'package:postgres/postgres.dart'; /// A [QueryExecutor] that queries a PostgreSQL database. class PostgreSqlExecutor extends QueryExecutor { - PostgreSQLExecutionContext _connection; + final Dialect _dialect = const PostgreSQLDialect(); + + ConnectionSettings? _settings; + Endpoint? _endpoint; + + Session _session; /// An optional [Logger] to print information to. A default logger will be used /// if not set late Logger logger; - PostgreSqlExecutor(this._connection, {Logger? logger}) { - this.logger = logger ?? Logger('PostgreSqlExecutor'); - } - - final Dialect _dialect = const PostgreSQLDialect(); - @override Dialect get dialect => _dialect; - /// The underlying connection. - PostgreSQLExecutionContext get connection => _connection; + /// The underlying database session. + Session get session => _session; + + PostgreSqlExecutor(this._session, + {Endpoint? endpoint, ConnectionSettings? settings, Logger? logger}) { + this.logger = logger ?? Logger('PostgreSqlExecutor'); + + _settings = settings; + _endpoint = endpoint; + } /// Closes the connection. - Future close() { - if (_connection is PostgreSQLConnection) { - return (_connection as PostgreSQLConnection).close(); - } else { - return Future.value(); + Future close() async { + if (_session is Connection) { + await (_session as Connection).close(); } + + return Future.value(); } @override - Future query( + Future query( String tableName, String query, Map substitutionValues, {String returningQuery = '', List returningFields = const []}) { if (returningFields.isNotEmpty) { @@ -44,8 +50,8 @@ class PostgreSqlExecutor extends QueryExecutor { query = '$query $returning'; } - //logger.fine('Query: $query'); - //logger.fine('Values: $substitutionValues'); + logger.fine('Query: $query'); + logger.fine('Values: $substitutionValues'); // Convert List into String var param = {}; @@ -57,28 +63,24 @@ class PostgreSqlExecutor extends QueryExecutor { } }); - return _connection - .query(query, substitutionValues: param) + return _session + .execute(Sql.named(query), parameters: param) .catchError((err) async { logger.warning(err); - if (err is PostgreSQLException) { + if (err is PgException) { // This is a hack to detect broken db connection - bool brokenConnection = - err.message?.contains("connection is not open") ?? false; + bool brokenConnection = err.message.contains("connection is not open"); if (brokenConnection) { - if (_connection is PostgreSQLConnection) { - // Open a new db connection - var currentConnection = _connection as PostgreSQLConnection; - currentConnection.close(); + // Open a new db session + if (_session is Connection) { + (_session as Connection).close(); logger.warning( "A broken database connection is detected. Creating a new database connection."); - var conn = _createNewConnection(currentConnection); - await conn.open(); - _connection = conn; + _session = await _createNewSession(); // Retry the query with the new db connection - return _connection.query(query, substitutionValues: param); + return _session.execute(Sql.named(query), parameters: param); } } } @@ -86,129 +88,36 @@ class PostgreSqlExecutor extends QueryExecutor { }); } - // Create a new database connection from an existing connection - PostgreSQLConnection _createNewConnection(PostgreSQLConnection conn) { - return PostgreSQLConnection(conn.host, conn.port, conn.databaseName, - username: conn.username, - password: conn.password, - useSSL: conn.useSSL, - timeZone: conn.timeZone, - timeoutInSeconds: conn.timeoutInSeconds); + // Create a new database connection + Future _createNewSession() async { + if (_endpoint != null) { + return await Connection.open(_endpoint!, settings: _settings); + } + + throw PgException("Unable to create new connection"); } @override Future transaction(FutureOr Function(QueryExecutor) f) async { - if (_connection is! PostgreSQLConnection) { - return await f(this); - } + //if (_connection is! PostgreSQLConnection) { + // return await f(this); + //} - var conn = _connection as PostgreSQLConnection; - T? returnValue; + var conn = _session as Connection; - var txResult = await conn.transaction((ctx) async { + return await conn.runTx((ctx) async { try { //logger.fine('Entering transaction'); var tx = PostgreSqlExecutor(ctx, logger: logger); - returnValue = await f(tx); - - return returnValue; + return await f(tx); } catch (e) { - ctx.cancelTransaction(reason: e.toString()); + ctx.rollback(); + //ctx.cancelTransaction(reason: e.toString()); + logger.warning("The transation has failed due to ", e); rethrow; } - }); - - if (txResult is PostgreSQLRollback) { - //if (txResult.reason == null) { - // throw StateError('The transaction was cancelled.'); - //} else { - throw StateError( - 'The transaction was cancelled with reason "${txResult.reason}".'); - //} - } else { - return returnValue!; - } - } -} - -/// A [QueryExecutor] that manages a pool of PostgreSQL connections. -class PostgreSqlExecutorPool extends QueryExecutor { - /// The maximum amount of concurrent connections. - final int size; - - /// Creates a new [PostgreSQLConnection], on demand. - /// - /// The created connection should **not** be open. - final PostgreSQLConnection Function() connectionFactory; - - /// An optional [Logger] to print information to. - late Logger logger; - - final List _connections = []; - int _index = 0; - final Pool _pool, _connMutex = Pool(1); - - PostgreSqlExecutorPool(this.size, this.connectionFactory, {Logger? logger}) - : _pool = Pool(size) { - if (logger != null) { - this.logger = logger; - } else { - this.logger = Logger('PostgreSqlExecutorPool'); - } - - assert(size > 0, 'Connection pool cannot be empty.'); - } - - final Dialect _dialect = const PostgreSQLDialect(); - - @override - Dialect get dialect => _dialect; - - /// Closes all connections. - Future close() async { - await _pool.close(); - await _connMutex.close(); - return Future.wait(_connections.map((c) => c.close())); - } - - Future _open() async { - if (_connections.isEmpty) { - _connections.addAll(await Future.wait(List.generate(size, (_) async { - //logger.fine('Spawning connections...'); - var conn = connectionFactory(); - await conn.open(); - //return conn - // .open() - // .then((_) => PostgreSqlExecutor(conn, logger: logger)); - return PostgreSqlExecutor(conn, logger: logger); - }))); - } - } - - Future _next() { - return _connMutex.withResource(() async { - await _open(); - if (_index >= size) _index = 0; - return _connections[_index++]; - }); - } - - @override - Future query( - String tableName, String query, Map substitutionValues, - {String returningQuery = '', List returningFields = const []}) { - return _pool.withResource(() async { - var executor = await _next(); - return executor.query(tableName, query, substitutionValues, - returningFields: returningFields); - }); - } - - @override - Future transaction(FutureOr Function(QueryExecutor) f) { - return _pool.withResource(() async { - var executor = await _next(); - return executor.transaction(f); + }).onError((error, stackTrace) { + throw StateError('The transaction was cancelled.'); }); } } diff --git a/packages/orm/angel_orm_postgres/pubspec.yaml b/packages/orm/angel_orm_postgres/pubspec.yaml index c2d12e87..d8a77255 100644 --- a/packages/orm/angel_orm_postgres/pubspec.yaml +++ b/packages/orm/angel_orm_postgres/pubspec.yaml @@ -1,17 +1,15 @@ name: angel3_orm_postgres -version: 8.1.1 +version: 8.1.0 description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions. homepage: https://angel3-framework.web.app/ repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_postgres -publish_to: none environment: sdk: '>=3.0.0 <4.0.0' dependencies: angel3_orm: ^8.0.0 logging: ^1.2.0 pool: ^1.5.0 - postgres: ^2.6.1 - postgres_pool: ^2.1.6 + postgres: ^3.0.0 dev_dependencies: belatuk_pretty_logging: ^6.1.0 angel3_orm_generator: ^8.0.0 diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index 2b80ec42..a3ecb299 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:angel3_orm/angel3_orm.dart'; import 'package:angel3_orm_postgres/angel3_orm_postgres.dart'; import 'package:logging/logging.dart'; -import 'package:postgres_pool/postgres_pool.dart'; +import 'package:postgres/postgres.dart'; FutureOr Function() pg(Iterable schemas) { // Use single connection @@ -19,19 +19,16 @@ FutureOr Function() pg(Iterable schemas) { Future closePg(QueryExecutor executor) async { if (executor is PostgreSqlExecutor) { await executor.close(); - //} else if (executor is PostgreSqlExecutorPool) { - // await executor.close(); - } else if (executor is PostgreSqlPoolExecutor) { - await executor.close(); } } Future connectToPostgres(Iterable schemas) async { - var conn = PostgreSQLConnection( - 'localhost', 5432, Platform.environment['POSTGRES_DB'] ?? 'orm_test', + var conn = await Connection.open(Endpoint( + host: 'localhost', + port: 5432, + database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', - password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'); - await conn.open(); + password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123')); // Run sql to create the tables for (var s in schemas) { From cc362fb704855cd0cba24e7ead27839a9ee62052 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 13 Jan 2024 17:50:20 +0800 Subject: [PATCH 2/7] Updated postgresql pool --- packages/orm/angel_orm_postgres/CHANGELOG.md | 2 +- packages/orm/angel_orm_postgres/README.md | 4 ++ .../orm/angel_orm_postgres/example/main.dart | 14 +++--- .../lib/src/orm_postgres.dart | 8 ++-- .../lib/src/orm_postgres_pool.dart | 16 +++---- .../orm/angel_orm_postgres/test/common.dart | 46 +++++-------------- 6 files changed, 35 insertions(+), 55 deletions(-) diff --git a/packages/orm/angel_orm_postgres/CHANGELOG.md b/packages/orm/angel_orm_postgres/CHANGELOG.md index 1fe2b716..acd5428a 100644 --- a/packages/orm/angel_orm_postgres/CHANGELOG.md +++ b/packages/orm/angel_orm_postgres/CHANGELOG.md @@ -3,9 +3,9 @@ ## 8.1.0 * Updated repository links -* Updated `postgres` to 3.0.0 * Updated `lints` to 3.0.0 * Fixed linter warnings +* [BREAKING] Updated `postgres` to 3.0.0 ## 8.0.0 diff --git a/packages/orm/angel_orm_postgres/README.md b/packages/orm/angel_orm_postgres/README.md index 9a1e8500..11f27dee 100644 --- a/packages/orm/angel_orm_postgres/README.md +++ b/packages/orm/angel_orm_postgres/README.md @@ -12,3 +12,7 @@ PostgreSQL support for Angel3 ORM. * PostgreSQL version 10 or greater For documentation about the ORM, see [Developer Guide](https://angel3-docs.dukefirehawk.com/guides/orm) + +## Migration + +Posrgresql is upgraded from 2.x.x to 3.x.x in version 8.1.0. diff --git a/packages/orm/angel_orm_postgres/example/main.dart b/packages/orm/angel_orm_postgres/example/main.dart index 1dcf0be8..b2bc8c69 100644 --- a/packages/orm/angel_orm_postgres/example/main.dart +++ b/packages/orm/angel_orm_postgres/example/main.dart @@ -1,19 +1,19 @@ import 'dart:io'; import 'package:angel3_orm_postgres/angel3_orm_postgres.dart'; +import 'package:postgres/postgres.dart'; void main() async { - var executor = PostgreSqlPoolExecutor(PgPool( - PgEndpoint( + var executor = PostgreSqlPoolExecutor(Pool.withEndpoints([ + Endpoint( host: 'localhost', port: 5432, database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123', - ), - settings: PgPoolSettings() - ..maxConnectionAge = Duration(hours: 1) - ..concurrency = 5, - )); + ) + ], + settings: PoolSettings( + maxConnectionAge: Duration(hours: 1), maxConnectionCount: 5))); var rows = await executor.query('users', 'SELECT * FROM users', {}); print(rows); diff --git a/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart b/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart index 24b30f4a..6708b657 100644 --- a/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart +++ b/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart @@ -105,13 +105,13 @@ class PostgreSqlExecutor extends QueryExecutor { var conn = _session as Connection; - return await conn.runTx((ctx) async { + return await conn.runTx((session) async { try { //logger.fine('Entering transaction'); - var tx = PostgreSqlExecutor(ctx, logger: logger); - return await f(tx); + var exec = PostgreSqlExecutor(session, logger: logger); + return await f(exec); } catch (e) { - ctx.rollback(); + session.rollback(); //ctx.cancelTransaction(reason: e.toString()); logger.warning("The transation has failed due to ", e); rethrow; diff --git a/packages/orm/angel_orm_postgres/lib/src/orm_postgres_pool.dart b/packages/orm/angel_orm_postgres/lib/src/orm_postgres_pool.dart index 9032e945..59278daf 100644 --- a/packages/orm/angel_orm_postgres/lib/src/orm_postgres_pool.dart +++ b/packages/orm/angel_orm_postgres/lib/src/orm_postgres_pool.dart @@ -2,13 +2,13 @@ import 'dart:async'; import 'dart:convert'; import 'package:angel3_orm/angel3_orm.dart'; import 'package:logging/logging.dart'; -import 'package:postgres_pool/postgres_pool.dart'; +import 'package:postgres/postgres.dart'; import '../angel3_orm_postgres.dart'; /// A [QueryExecutor] that uses `package:postgres_pool` for connetions pooling. class PostgreSqlPoolExecutor extends QueryExecutor { - final PgPool _pool; + final Pool _pool; /// An optional [Logger] to print information to. late Logger logger; @@ -23,7 +23,7 @@ class PostgreSqlPoolExecutor extends QueryExecutor { Dialect get dialect => _dialect; /// The underlying connection pooling. - PgPool get pool => _pool; + Pool get pool => _pool; /// Closes all the connections in the pool. Future close() { @@ -32,7 +32,7 @@ class PostgreSqlPoolExecutor extends QueryExecutor { /// Run query. @override - Future query( + Future query( String tableName, String query, Map substitutionValues, {String returningQuery = '', List returningFields = const []}) { if (returningFields.isNotEmpty) { @@ -54,16 +54,16 @@ class PostgreSqlPoolExecutor extends QueryExecutor { } }); - return _pool.run((pgContext) async { - return await pgContext.query(query, substitutionValues: param); + return _pool.run((session) async { + return await session.execute(Sql.named(query), parameters: param); }); } /// Run query in a transaction. @override Future transaction(FutureOr Function(QueryExecutor) f) async { - return _pool.runTx((pgContext) async { - var exec = PostgreSqlExecutor(pgContext, logger: logger); + return _pool.runTx((session) async { + var exec = PostgreSqlExecutor(session, logger: logger); return await f(exec); }); } diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index a3ecb299..c8135533 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -9,9 +9,6 @@ FutureOr Function() pg(Iterable schemas) { // Use single connection return () => connectToPostgres(schemas); - // Use connection pooling with 1 connection - //return () => connectToPostgresPool(schemas); - // Use PostgreSqlExecutorPool (Not working) //return () => connectToPostgresPool1(schemas); } @@ -38,47 +35,26 @@ Future connectToPostgres(Iterable schemas) async { return PostgreSqlExecutor(conn, logger: Logger.root); } -Future connectToPostgresPool1( - Iterable schemas) async { - PostgreSQLConnection connectionFactory() { - return PostgreSQLConnection( - 'localhost', 5432, Platform.environment['POSTGRES_DB'] ?? 'orm_test', - username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', - password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'); - } - - PostgreSQLConnection conn = connectionFactory(); - await conn.open(); - - // Run sql to create the tables - for (var s in schemas) { - await conn.execute(await File('test/migrations/$s.sql').readAsString()); - } - - return PostgreSqlExecutorPool(5, connectionFactory, logger: Logger.root); -} - Future connectToPostgresPool( Iterable schemas) async { - var dbPool = PgPool( - PgEndpoint( + var dbPool = Pool.withEndpoints([ + Endpoint( host: 'localhost', port: 5432, database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123', - ), - settings: PgPoolSettings() - ..maxConnectionAge = Duration(hours: 1) - ..concurrency = 200, - ); + ) + ], + settings: PoolSettings( + maxConnectionAge: Duration(hours: 1), maxConnectionCount: 5)); // Run sql to create the tables in a transaction - //await _pool.runTx((conn) async { - // for (var s in schemas) { - // await conn.execute(await File('test/migrations/$s.sql').readAsString()); - // } - //}); + await dbPool.runTx((conn) async { + for (var s in schemas) { + await conn.execute(await File('test/migrations/$s.sql').readAsString()); + } + }); return PostgreSqlPoolExecutor(dbPool, logger: Logger.root); } From b9b59523efd96bb2759b9b17a681abc66974f0d4 Mon Sep 17 00:00:00 2001 From: thomashii Date: Thu, 25 Jan 2024 12:14:23 +0800 Subject: [PATCH 3/7] Updated migration runner --- .../angel_migration_runner/example/main.dart | 10 ++++++-- .../lib/src/postgres/runner.dart | 25 +++++++++---------- .../lib/src/postgres/schema.dart | 10 ++++---- .../orm/angel_migration_runner/pubspec.yaml | 4 +-- .../orm/angel_orm_postgres/test/common.dart | 1 + 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/packages/orm/angel_migration_runner/example/main.dart b/packages/orm/angel_migration_runner/example/main.dart index 7f8f2aa8..e7a4926c 100755 --- a/packages/orm/angel_migration_runner/example/main.dart +++ b/packages/orm/angel_migration_runner/example/main.dart @@ -9,9 +9,15 @@ import 'package:mysql_client/mysql_client.dart'; import 'todo.dart'; void main(List args) async { + Connection conn = await Connection.open(Endpoint( + host: 'localhost', + port: 5432, + database: 'demo', + username: 'demouser', + password: 'demo123')); + var postgresqlMigrationRunner = PostgresMigrationRunner( - PostgreSQLConnection('localhost', 5432, 'demo', - username: 'demouser', password: 'demo123'), + conn, migrations: [ UserMigration(), TodoMigration(), diff --git a/packages/orm/angel_migration_runner/lib/src/postgres/runner.dart b/packages/orm/angel_migration_runner/lib/src/postgres/runner.dart index 90715061..8f1b33bc 100755 --- a/packages/orm/angel_migration_runner/lib/src/postgres/runner.dart +++ b/packages/orm/angel_migration_runner/lib/src/postgres/runner.dart @@ -11,7 +11,7 @@ class PostgresMigrationRunner implements MigrationRunner { final _log = Logger('PostgresMigrationRunner'); final Map migrations = {}; - final PostgreSQLConnection connection; + final Connection connection; final Queue _migrationQueue = Queue(); bool _connected = false; @@ -34,7 +34,8 @@ class PostgresMigrationRunner implements MigrationRunner { } if (!_connected) { - await connection.open(); + //await connection.open(); + //Connection.open(_endpoint!, settings: _settings); _connected = true; } @@ -55,7 +56,7 @@ class PostgresMigrationRunner implements MigrationRunner { @override Future up() async { await _init(); - var r = await connection.query('SELECT path from migrations;'); + var r = await connection.execute('SELECT path from migrations;'); var existing = r.expand((x) => x).cast(); var toRun = []; @@ -64,7 +65,7 @@ class PostgresMigrationRunner implements MigrationRunner { }); if (toRun.isNotEmpty) { - var r = await connection.query('SELECT MAX(batch) from migrations;'); + var r = await connection.execute('SELECT MAX(batch) from migrations;'); var curBatch = (r[0][0] ?? 0) as int; var batch = curBatch + 1; @@ -74,16 +75,15 @@ class PostgresMigrationRunner implements MigrationRunner { migration.up(schema); _log.info('Added "$k" into "migrations" table.'); await schema.run(connection).then((_) { - return connection.transaction((ctx) async { - var result = await ctx.query( + return connection.runTx((ctx) async { + var result = await ctx.execute( "INSERT INTO MIGRATIONS (batch, path) VALUES ($batch, '$k')"); - return result.affectedRowCount; + return result.affectedRows; }); - //return connection.execute( - // 'INSERT INTO MIGRATIONS (batch, path) VALUES ($batch, \'$k\');'); }).catchError((e) { _log.severe('Failed to insert into "migrations" table.'); + return -1; }); } } else { @@ -95,11 +95,10 @@ class PostgresMigrationRunner implements MigrationRunner { Future rollback() async { await _init(); - PostgreSQLResult r = - await connection.query('SELECT MAX(batch) from migrations;'); + Result r = await connection.execute('SELECT MAX(batch) from migrations;'); var curBatch = (r[0][0] ?? 0) as int; r = await connection - .query('SELECT path from migrations WHERE batch = $curBatch;'); + .execute('SELECT path from migrations WHERE batch = $curBatch;'); var existing = r.expand((x) => x).cast(); var toRun = []; @@ -127,7 +126,7 @@ class PostgresMigrationRunner implements MigrationRunner { Future reset() async { await _init(); var r = await connection - .query('SELECT path from migrations ORDER BY batch DESC;'); + .execute('SELECT path from migrations ORDER BY batch DESC;'); var existing = r.expand((x) => x).cast(); var toRun = existing.where(migrations.containsKey).toList(); diff --git a/packages/orm/angel_migration_runner/lib/src/postgres/schema.dart b/packages/orm/angel_migration_runner/lib/src/postgres/schema.dart index 2a1d4aa0..d287a983 100755 --- a/packages/orm/angel_migration_runner/lib/src/postgres/schema.dart +++ b/packages/orm/angel_migration_runner/lib/src/postgres/schema.dart @@ -14,18 +14,18 @@ class PostgresSchema extends Schema { factory PostgresSchema() => PostgresSchema._(StringBuffer(), 0); - Future run(PostgreSQLConnection connection) async { + Future run(Connection connection) async { //return connection.execute(compile()); - var result = await connection.transaction((ctx) async { + var result = await connection.runTx((ctx) async { var sql = compile(); - var result = await ctx.query(sql).catchError((e) { + var result = await ctx.execute(sql).catchError((e) { _log.severe('Failed to run query: [ $sql ]', e); throw Exception(e); }); - return result.affectedRowCount; + return result.affectedRows; }); - return (result is int) ? result : 0; + return result; } String compile() => _buf.toString(); diff --git a/packages/orm/angel_migration_runner/pubspec.yaml b/packages/orm/angel_migration_runner/pubspec.yaml index e230d76a..1df937db 100755 --- a/packages/orm/angel_migration_runner/pubspec.yaml +++ b/packages/orm/angel_migration_runner/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_migration_runner -version: 8.1.1 +version: 8.2.0 description: Command-line based database migration runner for Angel3's ORM. homepage: https://angel3-framework.web.app/ repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_migration_runner @@ -11,7 +11,7 @@ dependencies: angel3_orm: ^8.0.0 args: ^2.4.0 charcode: ^1.3.0 - postgres: ^2.6.0 + postgres: ^3.0.0 mysql_client: ^0.0.27 mysql1: ^0.20.0 logging: ^1.2.0 diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index c8135533..daac0d2e 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -20,6 +20,7 @@ Future closePg(QueryExecutor executor) async { } Future connectToPostgres(Iterable schemas) async { + // postgres://kfayrlbi:OAaEE39zOMLEPfH4DDgHbGNVsQtNdHu7@heffalump.db.elephantsql.com/kfayrlbi var conn = await Connection.open(Endpoint( host: 'localhost', port: 5432, From ae3544396c464391e31c6c0f22ef34e2603f98d7 Mon Sep 17 00:00:00 2001 From: thomashii Date: Thu, 25 Jan 2024 12:48:43 +0800 Subject: [PATCH 4/7] Updated change log --- packages/orm/angel_migration_runner/CHANGELOG.md | 4 ++++ packages/orm/angel_migration_runner/README.md | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/orm/angel_migration_runner/CHANGELOG.md b/packages/orm/angel_migration_runner/CHANGELOG.md index 0f5e89cd..f0b5a981 100755 --- a/packages/orm/angel_migration_runner/CHANGELOG.md +++ b/packages/orm/angel_migration_runner/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 8.2.0 + +* [BREAKING] Updated `postgres` to 3.0.0 + ## 8.1.1 * Updated repository link diff --git a/packages/orm/angel_migration_runner/README.md b/packages/orm/angel_migration_runner/README.md index a0987631..a4011619 100755 --- a/packages/orm/angel_migration_runner/README.md +++ b/packages/orm/angel_migration_runner/README.md @@ -19,10 +19,15 @@ Supported database: * Use `MySqlMigrationRunner` to perform database migration for MySQL and MariaDB. This runner is using [`mysql_client`](https://pub.dev/packages?q=mysql_client) driver. -* Use `MariaDbMigrationRunner` to perform database migration for MariaDB. This runner is using[`mysql1`](https://pub.dev/packages?q=mysql1) driver. +* Use `MariaDbMigrationRunner` to perform database migration for MariaDB. This runner is using [`mysql1`](https://pub.dev/packages?q=mysql1) driver. ## Supported Operations -* reset - Clear out all records in the `migrations` table and drop all the managed ORM tables. -* up - Generate all the managed ORM tables based on the ORM models. +* reset - Clear out all records in the `migrations` table and drop all the ORM related tables. +* up - Generate all the tables based on the ORM models. * refresh - Run `reset` follow by `up` + +## To do + +* Update existing tables +* Reverse engineer tables into models From fe44b0f60b7d7b3906c1b77b76e25d98aa7cb186 Mon Sep 17 00:00:00 2001 From: thomashii Date: Mon, 12 Feb 2024 12:31:33 +0800 Subject: [PATCH 5/7] Updated to support postgresql 3 driver --- .../angel_migration_runner/example/main.dart | 29 ++++++++++++------- packages/orm/angel_orm/lib/src/query.dart | 2 +- .../orm/angel_orm_postgres/example/main.dart | 2 +- packages/orm/angel_orm_postgres/pubspec.yaml | 10 +++---- .../orm/angel_orm_postgres/test/common.dart | 20 ++++++++----- .../lib/src/custom_expr_test.dart | 6 +++- 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/packages/orm/angel_migration_runner/example/main.dart b/packages/orm/angel_migration_runner/example/main.dart index e7a4926c..d0ec7fe8 100755 --- a/packages/orm/angel_migration_runner/example/main.dart +++ b/packages/orm/angel_migration_runner/example/main.dart @@ -1,20 +1,27 @@ +import 'dart:io'; + import 'package:angel3_migration/angel3_migration.dart'; import 'package:angel3_migration_runner/angel3_migration_runner.dart'; import 'package:angel3_migration_runner/postgres.dart'; -import 'package:angel3_migration_runner/mysql.dart'; import 'package:angel3_orm/angel3_orm.dart'; import 'package:postgres/postgres.dart'; -import 'package:mysql_client/mysql_client.dart'; import 'todo.dart'; void main(List args) async { + var host = Platform.environment['DB_HOST'] ?? 'localhost'; + var database = Platform.environment['DB_NAME'] ?? 'demo'; + var username = Platform.environment['DB_USERNAME'] ?? 'demouser'; + var password = Platform.environment['DB_PASSWORD'] ?? 'demo123'; + + print("$host $database $username $password"); + Connection conn = await Connection.open(Endpoint( - host: 'localhost', + host: host, port: 5432, - database: 'demo', - username: 'demouser', - password: 'demo123')); + database: database, + username: username, + password: password)); var postgresqlMigrationRunner = PostgresMigrationRunner( conn, @@ -25,12 +32,13 @@ void main(List args) async { ], ); + /* var mySQLConn = await MySQLConnection.createConnection( - host: "localhost", + host: host, port: 3306, - databaseName: "orm_test", - userName: "test", - password: "Test123*", + databaseName: database, + userName: username, + password: password, secure: false); // ignore: unused_local_variable @@ -42,6 +50,7 @@ void main(List args) async { FooMigration(), ], ); + */ runMigrations(postgresqlMigrationRunner, args); } diff --git a/packages/orm/angel_orm/lib/src/query.dart b/packages/orm/angel_orm/lib/src/query.dart index e5bdb612..b8145d0f 100644 --- a/packages/orm/angel_orm/lib/src/query.dart +++ b/packages/orm/angel_orm/lib/src/query.dart @@ -392,7 +392,7 @@ abstract class Query extends QueryBase { throw ArgumentError("Unsupported database dialect."); } - //_log.warning("Insert Query = $sql"); + _log.fine("Insert Query = $sql"); return executor .query(tableName, sql, substitutionValues, diff --git a/packages/orm/angel_orm_postgres/example/main.dart b/packages/orm/angel_orm_postgres/example/main.dart index b2bc8c69..8fc33fc0 100644 --- a/packages/orm/angel_orm_postgres/example/main.dart +++ b/packages/orm/angel_orm_postgres/example/main.dart @@ -5,7 +5,7 @@ import 'package:postgres/postgres.dart'; void main() async { var executor = PostgreSqlPoolExecutor(Pool.withEndpoints([ Endpoint( - host: 'localhost', + host: Platform.environment['POSTGRES_HOSTNAME'] ?? 'localhost', port: 5432, database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', diff --git a/packages/orm/angel_orm_postgres/pubspec.yaml b/packages/orm/angel_orm_postgres/pubspec.yaml index d8a77255..2eb7c2d9 100644 --- a/packages/orm/angel_orm_postgres/pubspec.yaml +++ b/packages/orm/angel_orm_postgres/pubspec.yaml @@ -16,18 +16,18 @@ dev_dependencies: angel3_orm_test: ^8.0.0 test: ^1.24.0 lints: ^3.0.0 -# dependency_overrides: +dependency_overrides: # angel3_serialize: # path: ../../serialize/angel_serialize # angel3_serialize_generator: # path: ../../serialize/angel_serialize_generator # angel3_model: # path: ../../model -# angel3_orm_test: -# path: ../angel_orm_test + angel3_orm_test: + path: ../angel_orm_test # angel3_orm_generator: # path: ../angel_orm_generator # angel3_orm: # path: ../angel_orm -# angel3_migration: -# path: ../angel_migration + angel3_migration: + path: ../angel_migration diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index daac0d2e..4257eae9 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -20,13 +20,19 @@ Future closePg(QueryExecutor executor) async { } Future connectToPostgres(Iterable schemas) async { - // postgres://kfayrlbi:OAaEE39zOMLEPfH4DDgHbGNVsQtNdHu7@heffalump.db.elephantsql.com/kfayrlbi - var conn = await Connection.open(Endpoint( - host: 'localhost', - port: 5432, - database: Platform.environment['POSTGRES_DB'] ?? 'orm_test', - username: Platform.environment['POSTGRES_USERNAME'] ?? 'test', - password: Platform.environment['POSTGRES_PASSWORD'] ?? 'test123')); + var host = Platform.environment['POSTGRES_HOST'] ?? 'localhost'; + var database = Platform.environment['POSTGRES_NAME'] ?? 'orm_test'; + var username = Platform.environment['POSTGRES_USERNAME'] ?? 'test'; + var password = Platform.environment['POSTGRES_PASSWORD'] ?? 'test123'; + + var conn = await Connection.open( + Endpoint( + host: host, + port: 5432, + database: database, + username: username, + password: password), + settings: ConnectionSettings(sslMode: SslMode.disable)); // Run sql to create the tables for (var s in schemas) { diff --git a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart index 4ab71f94..0acfc03f 100644 --- a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart +++ b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart @@ -24,7 +24,11 @@ void customExprTests(FutureOr Function() createExecutor, }); }); - tearDown(() => close!(executor)); + tearDown(() { + if (close != null) { + close(executor); + } + }); test('fetches correct result', () async { expect(numbersModel.two, 2); From bee328e1c12eaf41fb4342faa50d221703fa90a6 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 17 Feb 2024 19:18:23 +0800 Subject: [PATCH 6/7] Updated postgres --- packages/orm/angel_orm_postgres/pubspec.yaml | 4 +- .../orm/angel_orm_postgres/test/common.dart | 37 ++++++++++++++++++- .../lib/src/custom_expr_test.dart | 5 ++- packages/orm/angel_orm_test/pubspec.yaml | 6 +-- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/packages/orm/angel_orm_postgres/pubspec.yaml b/packages/orm/angel_orm_postgres/pubspec.yaml index 2eb7c2d9..d66f391e 100644 --- a/packages/orm/angel_orm_postgres/pubspec.yaml +++ b/packages/orm/angel_orm_postgres/pubspec.yaml @@ -27,7 +27,7 @@ dependency_overrides: path: ../angel_orm_test # angel3_orm_generator: # path: ../angel_orm_generator -# angel3_orm: -# path: ../angel_orm + angel3_orm: + path: ../angel_orm angel3_migration: path: ../angel_migration diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index 4257eae9..664469ec 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -36,7 +36,42 @@ Future connectToPostgres(Iterable schemas) async { // Run sql to create the tables for (var s in schemas) { - await conn.execute(await File('test/migrations/$s.sql').readAsString()); + var rawQueryString = await File('test/migrations/$s.sql').readAsString(); + print("Raw SQL Query: $rawQueryString"); + //await conn.execute(queryString); + + // Split the queries and execute them + var stringLen = rawQueryString.length; + var index = 0; + while (index < stringLen) { + index = rawQueryString.indexOf(";"); + if (index < 0) { + break; + } + var query = rawQueryString.substring(0, index); + print("SQL Query: $query;"); + await conn.execute("$query;"); + + index++; + if (index < stringLen) { + var tempString = rawQueryString.substring(index).trim(); + rawQueryString = tempString; + stringLen = rawQueryString.length; + index = 0; + } + } + /* + var queryString = rawQueryString.replaceAll("\n", " "); + print("Raw Query: $queryString"); + var queries = queryString.split(';'); + for (var rawQuery in queries) { + var query = rawQuery.trim(); + if (query.isNotEmpty) { + print("SQL Query: $query;"); + await conn.execute("$query;"); + } + } + */ } return PostgreSqlExecutor(conn, logger: Logger.root); diff --git a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart index 0acfc03f..68941fd4 100644 --- a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart +++ b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart @@ -10,8 +10,11 @@ void customExprTests(FutureOr Function() createExecutor, close ??= (_) => null; + var hasExecutor = false; + setUp(() async { executor = await createExecutor(); + hasExecutor = true; var now = DateTime.now(); var nQuery = NumbersQuery(); @@ -25,7 +28,7 @@ void customExprTests(FutureOr Function() createExecutor, }); tearDown(() { - if (close != null) { + if (hasExecutor && close != null) { close(executor); } }); diff --git a/packages/orm/angel_orm_test/pubspec.yaml b/packages/orm/angel_orm_test/pubspec.yaml index ca73e7e3..4b0fc529 100644 --- a/packages/orm/angel_orm_test/pubspec.yaml +++ b/packages/orm/angel_orm_test/pubspec.yaml @@ -19,7 +19,7 @@ dev_dependencies: angel3_framework: ^8.0.0 build_runner: ^2.4.0 lints: ^3.0.0 -# dependency_overrides: +dependency_overrides: # angel3_container: # path: ../../container/angel_container # angel3_framework: @@ -36,8 +36,8 @@ dev_dependencies: # path: ../../serialize/angel_serialize # angel3_serialize_generator: # path: ../../serialize/angel_serialize_generator -# angel3_orm: -# path: ../angel_orm + angel3_orm: + path: ../angel_orm # angel3_migration: # path: ../angel_migration # angel3_orm_generator: From 630f7c16ec58327bf4b4c5e2fbcfe5d61250667f Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 18 Feb 2024 12:03:36 +0800 Subject: [PATCH 7/7] Updated postgres configurations --- packages/orm/angel_orm_postgres/test/common.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index 664469ec..6464b73f 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -21,7 +21,7 @@ Future closePg(QueryExecutor executor) async { Future connectToPostgres(Iterable schemas) async { var host = Platform.environment['POSTGRES_HOST'] ?? 'localhost'; - var database = Platform.environment['POSTGRES_NAME'] ?? 'orm_test'; + var database = Platform.environment['POSTGRES_DB'] ?? 'orm_test'; var username = Platform.environment['POSTGRES_USERNAME'] ?? 'test'; var password = Platform.environment['POSTGRES_PASSWORD'] ?? 'test123';