generated from MasoniteFramework/starter-package
-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from eaguad1337/feat/860
implement migrate:fresh
- Loading branch information
Showing
10 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from ..migrations import Migration | ||
|
||
from .Command import Command | ||
|
||
|
||
class MigrateFreshCommand(Command): | ||
""" | ||
Drops all tables and migrates them again. | ||
migrate:fresh | ||
{--c|connection=default : The connection you want to run migrations on} | ||
{--d|directory=databases/migrations : The location of the migration directory} | ||
{--f|ignore-fk=? : The connection you want to run migrations on} | ||
{--s|seed=? : Seed database after fresh. The seeder to be ran can be provided in argument} | ||
{--schema=? : Sets the schema to be migrated} | ||
{--D|seed-directory=databases/seeds : The location of the seed directory if seed option is used.} | ||
""" | ||
|
||
def handle(self): | ||
migration = Migration( | ||
command_class=self, | ||
connection=self.option("connection"), | ||
migration_directory=self.option("directory"), | ||
config_path=self.option("config"), | ||
schema=self.option("schema"), | ||
) | ||
|
||
migration.fresh(ignore_fk=self.option("ignore-fk")) | ||
|
||
self.line("") | ||
|
||
if self.option("seed") == "null": | ||
self.call( | ||
"seed:run", | ||
f"None --directory {self.option('seed-directory')} --connection {self.option('connection')}", | ||
) | ||
|
||
elif self.option("seed"): | ||
self.call( | ||
"seed:run", | ||
f"{self.option('seed')} --directory {self.option('seed-directory')} --connection {self.option('connection')}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters