File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import 'dart:math';
99import 'package:clock/clock.dart' ;
1010import 'package:gcloud/service_scope.dart' as ss;
1111import 'package:meta/meta.dart' ;
12+ import 'package:path/path.dart' as p;
1213import 'package:postgres/postgres.dart' ;
1314import 'package:pub_dev/database/migration.dart' ;
1415import 'package:pub_dev/database/schema.dart' ;
@@ -127,14 +128,22 @@ class PrimaryDatabase {
127128 ).replaceFirst ('CREATE TABLE "' , 'CREATE TABLE IF NOT EXISTS "' );
128129 await _pg.execute (createSql);
129130
130- // TODO: replace with real migration SQL files
131+ // Read SQL migration files
132+ final files = Directory ('migrations' )
133+ .listSync ()
134+ .whereType <File >()
135+ .where ((f) => f.path.endsWith ('.sql' ))
136+ .toList ();
137+ files.sort ((a, b) => a.path.compareTo (b.path));
138+ final scripts = files
139+ .map ((f) => (name: p.basename (f.path), content: f.readAsStringSync ()))
140+ .toList ();
141+
131142 await migrateScripts (
132143 target: _adapter,
133144 table: migrationDb.schema_migrations,
134145 migrationsName: 'pub-dev' ,
135- scripts: [
136- (name: 'primary.sql' , content: createPrimarySchemaTables (_dialect)),
137- ],
146+ scripts: scripts,
138147 );
139148 }
140149
You can’t perform that action at this time.
0 commit comments