https://github.com/f3ath/migrant-db-postgresql
PostgreSQL gateway for migrant.
https://github.com/f3ath/migrant-db-postgresql
dart migration migration-tool postgresql
Last synced: 11 months ago
JSON representation
PostgreSQL gateway for migrant.
- Host: GitHub
- URL: https://github.com/f3ath/migrant-db-postgresql
- Owner: f3ath
- License: mit
- Created: 2022-05-01T03:06:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T01:53:47.000Z (over 1 year ago)
- Last Synced: 2025-04-22T18:59:53.763Z (about 1 year ago)
- Topics: dart, migration, migration-tool, postgresql
- Language: Dart
- Homepage: https://pub.dev/packages/migrant_db_postgresql
- Size: 20.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
PostgreSQL gateway for [migrant](https://pub.dev/packages/migrant).
Example:
```dart
import 'package:migrant/migrant.dart';
import 'package:migrant/testing.dart';
import 'package:migrant_db_postgresql/migrant_db_postgresql.dart';
import 'package:postgres/postgres.dart';
Future main() async {
// These are the migrations. We are using a simple in-memory source,
// but you may read them from other sources: local filesystem, network, etc.
// More options at https://pub.dev/packages/migrant
final migrations = InMemory([
Migration('0001', ['CREATE TABLE foo (id TEXT NOT NULL PRIMARY KEY);']),
Migration('0002', ['ALTER TABLE foo ADD COLUMN message TEXT;']),
// Try adding more stuff here and running this example again.
]);
// The postgres connection. To make it work, you need an actual server.
// Try it with Docker:
// docker run -d -p 5432:5432 --name my-postgres -e POSTGRES_PASSWORD=postgres postgres
final connection = await Connection.open(
Endpoint(
host: 'localhost',
database: 'postgres',
username: 'postgres',
password: 'postgres',
),
settings: ConnectionSettings(sslMode: SslMode.disable));
// The gateway is provided by this package.
final gateway = PostgreSQLGateway(connection);
// Applying migrations.
await Database(gateway).upgrade(migrations);
// At this point the table "foo" is ready. We're done.
await connection.close();
}
```