Example #1
0
 public static function roll_back($migration_file, $all = false)
 {
     self::find_or_create_schema_migrations_table();
     if (schema_migration::read("version = '" . basename($migration_file) . "'")->count && !$all) {
         throw new moojon_exception("No such migration ({$migration_file})");
     }
     foreach (schema_migration::read(null, 'version DESC') as $migration) {
         if (self::get_migration_class_name($migration->version) == $migration_file . '_migration') {
             break;
         }
         self::run_migration($migration->version, 'down');
     }
 }
Example #2
0
 public static function get_schema_version()
 {
     if (in_array('schema_migrations', self::show_tables(''))) {
         return schema_migration::read(null, 'version DESC')->first->version;
     } else {
         return 0;
     }
 }