File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,7 @@ public static function bootHasSchemaVersion(): void
22
22
});
23
23
24
24
static ::retrieved (function ($ model ) {
25
- if ($ model ->getSchemaVersion () < $ model ->currentSchemaVersion ) {
26
- $ model ->migrateSchema ($ model ->getSchemaVersion ());
27
- }
25
+ $ model ->migrateSchema ($ model ->upgradeSchemaVersion ());
28
26
});
29
27
}
30
28
@@ -35,6 +33,20 @@ public function migrateSchema(int $fromVersion): void
35
33
{
36
34
}
37
35
36
+ /**
37
+ * migrate schema and set current model version
38
+ * @return void
39
+ */
40
+ public function upgradeSchemaVersion (): void
41
+ {
42
+ $ version = $ this ->getSchemaVersion ();
43
+
44
+ if ($ version && $ version < $ this ->currentSchemaVersion ) {
45
+ $ this ->migrateSchema ($ version );
46
+ $ this ->setSchemaVersion ($ this ->currentSchemaVersion );
47
+ }
48
+ }
49
+
38
50
/**
39
51
* Get Current document version
40
52
*
You can’t perform that action at this time.
0 commit comments