db_schema_migration 0.0.1

  • README.md
  • Installing
  • Versions
  • 21

Database schema migration

A database schema migration tool, to execute the proper sequence of SQL commands that are required to get your DB to the desired state.

The sequence of operations is defined by the sorted order of versions. Versions are semver, and single numbers (1, 2) will be transformed accordingly (1.0.0, 2.0.0).


A simple usage example:

import 'dart:async';

import 'package:db_schema_migration/db_schema_migration.dart';
import 'package:db_schema_migration/postgresql.dart';

import 'package:postgresql/postgresql.dart';

Future main() async {
  Connection connection = await _getConnection();
  var migrator = new PostgresqlSchemaMigrator();
  var migrations = new Migrations();
      'CREATE TABLE user(name VARCHAR(127) PRIMARY KEY, password_hash VARCHAR(127));');
  migrations.add(2, 'ALTER TABLE user ADD COLUMN address varchar(127);');
  await migrator.migrate(connection, 'user', migrations);
  // Now the DB has a user table with name, password_hash and address columns.

Some usage patterns

How to group migrations:

  • per-table migration scripts
    • for each table, there is a separate sequence of migrations
    • foreign keys must be run as separate migrations after the regular tables are done
  • per-package migration scripts (recommended)
    • related tables, FKs and indexes are sharing a sequence of migrations

How to version migrations:

  • regular numbers: 1, 2, 3, ...
  • date + number: 20161204.1, 20161204.2, ...
  • date + package id + sequence: 20161204.134.1, 20161204.134.2, ...

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  db_schema_migration: "^0.0.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:db_schema_migration/db_schema_migration.dart';
Version Uploaded Documentation Archive
0.0.1 Dec 4, 2016 Go to the documentation of db_schema_migration 0.0.1 Download db_schema_migration 0.0.1 archive


We analyzed this package on Jun 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
53 / 100
Reflects how tidy and up-to-date the package is. [more]
24 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: unsure

Error(s) prevent platform classification:

Error(s) in lib/postgresql.dart: Target of URI doesn't exist: 'package:postgresql/postgresql.dart'.


  • Fix platform conflicts.

    Error(s) prevent platform classification:

    Error(s) in lib/postgresql.dart: Target of URI doesn't exist: 'package:postgresql/postgresql.dart'.

  • Running dartdoc failed.

    Make sure dartdoc runs without any issues.

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 8 errors.

    Make sure that the imported libraries are not in conflict. Error(s) in lib/postgresql.dart: Target of URI doesn't exist: 'package:postgresql/postgresql.dart'.

  • Package is getting outdated.

    The package was released 80 weeks ago.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use db_schema_migration.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
pub_semver >=1.3.0 <2.0.0 1.4.1
Transitive dependencies
collection 1.14.10
Dev dependencies
postgresql any
test >=0.12.0 <0.13.0