@@ -16,12 +16,12 @@ public function __construct(string $database) {
1616 $ this ->migrations = [];
1717 $ db = UloleORM::getDatabase ($ this ->database );
1818 (new CreateMigrationsMigration ())->up ($ db );
19- UloleORM::register (" uloleorm_migrations " , MigrationModel::class);
19+ UloleORM::register (MigrationModel::class);
2020
2121 if (MigrationModel::table ($ this ->database )->count () == 0 ) {
2222 if ($ this ->logging ) echo "Creating first migration \n" ;
2323 $ migration = new MigrationModel ;
24- $ migration ->migrated_model = 'de\interaapps\ulole\orm\migration\table\CreateMigrationsMigration ' ;
24+ $ migration ->migratedModel = 'de\interaapps\ulole\orm\migration\table\CreateMigrationsMigration ' ;
2525 $ migration ->version = 0 ;
2626 $ migration ->save ();
2727 }
@@ -49,25 +49,25 @@ public function up(): Migrator {
4949 $ db = UloleORM::getDatabase ($ this ->database );
5050
5151 $ latestVersion = 0 ;
52- $ latestVersionObject = MigrationModel::table ($ this ->database )->orderBy ("version " , true )->get ();
52+ $ latestVersionObject = MigrationModel::table ($ this ->database )->orderBy ("version " , true )->first ();
5353 if ($ latestVersionObject !== null ) {
5454 $ latestVersion = $ latestVersionObject ->version ;
5555 }
5656
5757 $ newerVersion = $ latestVersion + 1 ;
5858 foreach ($ this ->migrations as $ clazz ) {
59- if (MigrationModel::table ($ this ->database )->where ("migrated_model " , $ clazz )->get () === null ) {
59+ if (MigrationModel::table ($ this ->database )->where ("migrated_model " , $ clazz )->first () === null ) {
6060 $ returnValue = (new $ clazz ())->up ($ db );
6161 if ($ returnValue === null )
6262 $ returnValue = true ;
6363 if ($ returnValue ) {
6464 $ migration = new MigrationModel ;
65- $ migration ->migrated_model = $ clazz ;
65+ $ migration ->migratedModel = $ clazz ;
6666 $ migration ->version = $ newerVersion ;
6767 if ($ migration ->save ())
68- if ($ this ->logging ) echo "Migrated " . $ migration ->migrated_model . "\n" ;
68+ if ($ this ->logging ) echo "Migrated " . $ migration ->migratedModel . "\n" ;
6969 else
70- if ($ this ->logging ) echo "[x] Couldn't migrated " . $ migration ->migrated_model . "\n" ;
70+ if ($ this ->logging ) echo "[x] Couldn't migrated " . $ migration ->migratedModel . "\n" ;
7171 }
7272 }
7373 }
@@ -78,7 +78,7 @@ public function down($down = 1): Migrator {
7878 $ db = UloleORM::getDatabase ($ this ->database );
7979
8080 $ version = 0 ;
81- $ latestVersionObject = MigrationModel::table ($ this ->database )->orderBy ("version " , true )->get ();
81+ $ latestVersionObject = MigrationModel::table ($ this ->database )->orderBy ("version " , true )->first ();
8282 if ($ latestVersionObject !== null ) {
8383 $ version = $ latestVersionObject ->version ;
8484 }
0 commit comments