Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.41.0"
"flutter": "3.44.4"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.3

- Allow file execution on postgres database

## 0.0.2

- Prevent dynamic passing Migration instead of Migration<T>
Expand Down
5 changes: 0 additions & 5 deletions melos.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions packages/nightingale/lib/src/context.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
abstract class MigrationContext<T> {
const MigrationContext(this.value);
const MigrationContext(this.context);

final T value;
final T context;

Future<void> executeCommand(String sql);
Future<void> executeFile(String file);
Expand Down
4 changes: 2 additions & 2 deletions packages/nightingale/lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MigrationRunner<T> {
await databaseContext.runTransaction((session) async {
final migration = migrations[i];
await migration.forward(session);
await history.record(session.value, i, migration.name);
await history.record(session.context, i, migration.name);
});
}
}
Expand All @@ -64,7 +64,7 @@ class MigrationRunner<T> {
if (migration.backward != null) {
await migration.backward!.call(session);
}
await history.remove(session.value, i, migration.name);
await history.remove(session.context, i, migration.name);
});
}
}
Expand Down
7 changes: 3 additions & 4 deletions packages/nightingale/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: nightingale
version: 0.0.2
version: 0.0.3
repository: https://github.com/Iconica-Development/nightingale/
description: A library for managing migrations.

publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/

environment:
sdk: ^3.10.0

resolution: workspace
environment:
sdk: ^3.12.2

dependencies:
args: ^2.7.0
Expand Down
4 changes: 4 additions & 0 deletions packages/postgres_nightingale/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.3

- Allow file execution on postgres database

## 0.0.2

- Prevent dynamic Migrations
Expand Down
42 changes: 31 additions & 11 deletions packages/postgres_nightingale/lib/src/implementation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@ import "package:nightingale/nightingale.dart";
import "package:postgres/postgres.dart";

class PostgresMigrationContext extends MigrationContext<Session> {
const PostgresMigrationContext(super.value);
const PostgresMigrationContext(
super.context, {
required this._endpoint,
});

final Endpoint _endpoint;

@override
Future<void> executeCommand(String sql) async => value.execute(sql);
Future<void> executeCommand(String sql) async => context.execute(sql);

@override
Future<void> executeFile(String file) async {
final result = await Process.run("psql", ["-f", file]);
final result = await Process.run(
"psql",
[
"-h ${_endpoint.host}",
"-p ${_endpoint.port}",
"-U ${_endpoint.username}",
"-d ${_endpoint.database}",
"-f $file",
],
environment: {"PGPASSWORD": "${_endpoint.password}"},
);

if (result.exitCode != 0) {
throw Exception("PSQL execution failure\n${result.stdout}");
}
Expand All @@ -21,24 +37,28 @@ class PostgresMigrationContext extends MigrationContext<Session> {
@override
Future<void> runTransaction(
Future<void> Function(MigrationContext<Session> session) executor,
) async {
final value = this.value;
return (value is Connection)
? await value.runTx((value) async => executor(withValue(value)))
: await executor(this);
}
) async => switch (context) {
final Connection context => await context.runTx(
(value) async => executor(withValue(value)),
),
_ => await executor(this),
};

PostgresMigrationContext withValue(Session value) =>
PostgresMigrationContext(value);
PostgresMigrationContext(value, endpoint: _endpoint);
}

class PostgresMigrationRunner extends MigrationRunner<Session> {
factory PostgresMigrationRunner({
required Session database,
required Endpoint endpoint,
required List<Migration<Session>> migrations,
}) => PostgresMigrationRunner._(
database: database,
contextGenerator: (database) async => PostgresMigrationContext(database),
contextGenerator: (database) async => PostgresMigrationContext(
database,
endpoint: endpoint,
),
migrations: migrations,
history: const PostgresMigrationHistory(),
);
Expand Down
7 changes: 3 additions & 4 deletions packages/postgres_nightingale/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: postgres_nightingale
version: 0.0.2
version: 0.0.3
repository: https://github.com/Iconica-Development/nightingale/
description: A package for managing migrations in postgres

publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/

environment:
sdk: ^3.10.0

resolution: workspace
environment:
sdk: ^3.12.2

dependencies:
meta: ^1.17.0
Expand Down
146 changes: 1 addition & 145 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "10.2.0"
ansi_styles:
dependency: transitive
description:
name: ansi_styles
sha256: "9c656cc12b3c27b17dd982b2cc5c0cfdfbdabd7bc8f3ae5e8542d9867b47ce8a"
url: "https://pub.dev"
source: hosted
version: "0.3.2+1"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -65,14 +57,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
cli_config:
dependency: transitive
description:
Expand All @@ -81,22 +65,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.0"
cli_launcher:
dependency: transitive
description:
name: cli_launcher
sha256: "17d2744fb9a254c49ec8eda582536abe714ea0131533e24389843a4256f82eac"
url: "https://pub.dev"
source: hosted
version: "0.3.2+1"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
url: "https://pub.dev"
source: hosted
version: "0.4.2"
collection:
dependency: transitive
description:
Expand All @@ -105,14 +73,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
conventional_commit:
dependency: transitive
description:
name: conventional_commit
sha256: c40b1b449ce2a63fa2ce852f35e3890b1e182f5951819934c0e4a66254bc0dc3
url: "https://pub.dev"
source: hosted
version: "0.6.1+1"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -177,22 +137,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.3"
graphs:
dependency: transitive
description:
name: graphs
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
http:
dependency: transitive
description:
name: http
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
url: "https://pub.dev"
source: hosted
version: "1.6.0"
http_multi_server:
dependency: transitive
description:
Expand All @@ -217,14 +161,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.5"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8
url: "https://pub.dev"
source: hosted
version: "4.11.0"
lints:
dependency: transitive
description:
Expand All @@ -249,14 +185,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.12.18"
melos:
dependency: "direct dev"
description:
name: melos
sha256: "7dcc4444d79b538ab8353bb38308f97e90b032984f75e8fd516fedfe8160b35e"
url: "https://pub.dev"
source: hosted
version: "7.4.0"
meta:
dependency: transitive
description:
Expand All @@ -273,14 +201,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mustache_template:
dependency: transitive
description:
name: mustache_template
sha256: "4326d0002ff58c74b9486990ccbdab08157fca3c996fe9e197aff9d61badf307"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
node_preamble:
dependency: transitive
description:
Expand All @@ -305,22 +225,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
url: "https://pub.dev"
source: hosted
version: "7.0.2"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
pool:
dependency: transitive
description:
Expand All @@ -337,22 +241,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.5.9"
process:
dependency: transitive
description:
name: process
sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744
url: "https://pub.dev"
source: hosted
version: "5.0.5"
prompts:
dependency: transitive
description:
name: prompts
sha256: "3773b845e85a849f01e793c4fc18a45d52d7783b4cb6c0569fad19f9d0a774a1"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
pub_semver:
dependency: transitive
description:
Expand All @@ -361,22 +249,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.0"
pub_updater:
dependency: transitive
description:
name: pub_updater
sha256: "739a0161d73a6974c0675b864fb0cf5147305f7b077b7f03a58fa7a9ab3e7e7d"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082"
url: "https://pub.dev"
source: hosted
version: "1.5.0"
shelf:
dependency: transitive
description:
Expand Down Expand Up @@ -553,14 +425,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
xml:
dependency: transitive
description:
name: xml
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
url: "https://pub.dev"
source: hosted
version: "6.6.1"
yaml:
dependency: transitive
description:
Expand All @@ -569,13 +433,5 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.3"
yaml_edit:
dependency: transitive
description:
name: yaml_edit
sha256: "07c9e63ba42519745182b88ca12264a7ba2484d8239958778dfe4d44fe760488"
url: "https://pub.dev"
source: hosted
version: "2.2.4"
sdks:
dart: ">=3.10.0 <4.0.0"
dart: ">=3.12.2 <4.0.0"
Loading
Loading