@@ -4,6 +4,7 @@ var expect = require('expect.js');
44var Support = require ( __dirname + '/../../support' ) ;
55var helpers = require ( __dirname + '/../../support/helpers' ) ;
66var gulp = require ( 'gulp' ) ;
7+ var fs = require ( 'fs' ) ;
78
89( [
910 'db:migrate:undo'
@@ -63,5 +64,36 @@ var gulp = require('gulp');
6364 } ) ;
6465 } , 'db:migrate' ) ;
6566 } ) ;
67+
68+ it ( 'correctly undoes a named migration' , function ( done ) {
69+ var self = this ;
70+
71+ prepare ( function ( ) {
72+ var migrationsPath = Support . resolveSupportPath ( 'tmp' , 'migrations' ) ;
73+ var migrations = fs . readdirSync ( migrationsPath ) ;
74+ var createPersonMigration = migrations [ 0 ] ;
75+
76+ helpers . readTables ( self . sequelize , function ( tables ) {
77+ expect ( tables ) . to . have . length ( 2 ) ;
78+ expect ( tables [ 0 ] ) . to . equal ( 'Person' ) ;
79+
80+ gulp
81+ . src ( Support . resolveSupportPath ( 'tmp' ) )
82+ . pipe ( helpers . copyMigration ( 'emptyMigration.js' ) )
83+ . pipe ( helpers . runCli ( 'db:migrate' ) )
84+ . pipe ( helpers . runCli ( flag + ' --name ' + createPersonMigration , { pipeStdout : true } ) )
85+ . pipe ( helpers . teardown ( function ( ) {
86+ helpers . readTables ( self . sequelize , function ( tables ) {
87+ expect ( tables ) . to . have . length ( 1 ) ;
88+ expect ( tables [ 0 ] ) . to . equal ( 'SequelizeMeta' ) ;
89+ helpers . countTable ( self . sequelize , 'SequelizeMeta' , function ( count ) {
90+ expect ( count ) . to . eql ( [ { count : 1 } ] ) ;
91+ done ( ) ;
92+ } ) ;
93+ } ) ;
94+ } ) ) ;
95+ } ) ;
96+ } , 'db:migrate' ) ;
97+ } ) ;
6698 } ) ;
6799} ) ;
0 commit comments