diff --git a/config/default.yaml b/config/default.yaml index 592be3d..fac269e 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -1,3 +1,12 @@ # Default server configuration. host: 127.0.0.1 -mongo_db: mongodb://localhost:27017/angel \ No newline at end of file +mongo_db: mongodb://localhost:27017/angel +db: + migrate: + database: angel + username: root + password: password + web: + database: angel + username: username + password: password \ No newline at end of file diff --git a/config/development.yaml b/config/development.yaml index a4b3d02..bcfffb6 100644 --- a/config/development.yaml +++ b/config/development.yaml @@ -1,6 +1,2 @@ # Development-only server configuration. -port: 3000 -furlong: - database: angel - username: root - password: password \ No newline at end of file +port: 3000 \ No newline at end of file diff --git a/lib/src/migrations/migrations.dart b/lib/src/migrations/migrations.dart new file mode 100644 index 0000000..09ec0b6 --- /dev/null +++ b/lib/src/migrations/migrations.dart @@ -0,0 +1,4 @@ +library angel.migrations; + +export 'util.dart'; +export 'schemas/user.dart'; \ No newline at end of file diff --git a/lib/src/migrations/schemas/user.dart b/lib/src/migrations/schemas/user.dart new file mode 100644 index 0000000..96f7ecc --- /dev/null +++ b/lib/src/migrations/schemas/user.dart @@ -0,0 +1,24 @@ +import 'dart:async'; +import 'package:furlong/furlong.dart'; + +class UsersMigration extends Migration { + @override + String get name => "Users table"; + + @override + Future create(Migrator migrator) async { + migrator.create("users", (table) { + table.id(); + table.string("username"); + table.string("email"); + table.string("password"); + table.dateTime("created_at"); + table.dateTime("updated_at").nullable = true; + }); + } + + @override + Future destroy(Migrator migrator) async { + migrator.drop(["users"]); + } +} \ No newline at end of file diff --git a/lib/migrations/migrations.dart b/lib/src/migrations/util.dart similarity index 96% rename from lib/migrations/migrations.dart rename to lib/src/migrations/util.dart index bd82b9a..5a0bccd 100644 --- a/lib/migrations/migrations.dart +++ b/lib/src/migrations/util.dart @@ -1,5 +1,3 @@ -library angel.migrations; - import 'dart:async'; import 'dart:io'; import 'package:angel_configuration/angel_configuration.dart'; @@ -10,7 +8,7 @@ import 'package:sqljocky/sqljocky.dart'; Future createPool() async { var app = new Angel(); await app.configure(loadConfigurationFile()); - Map config = app.properties["furlong"]; + Map config = app.properties["db"]["migrate"]; if (config == null) throw new Exception( diff --git a/pubspec.yaml b/pubspec.yaml index 947c5e8..b5e6591 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,8 +12,7 @@ dependencies: angel_mongo: ^1.0.0-dev angel_mustache: ^1.0.0-dev angel_static: ^1.0.0 - furlong: - path: /Users/tobe/Source/Dart/furlong + furlong: ^1.0.0-dev json_god: ^2.0.0-beta validate: ^1.5.2 dev_dependencies: diff --git a/tool/grind.dart b/tool/grind.dart index fba5f05..a82b761 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -1,9 +1,10 @@ -import 'package:angel/migrations/migrations.dart'; +import 'package:angel/src/migrations/migrations.dart'; import 'package:furlong/furlong.dart'; import 'package:grinder/grinder.dart'; final List migrations = [ // Your migrations here! + new UsersMigration() ]; main(args) => grind(args);