PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.2.0
Independent Analytics – WordPress Analytics Plugin v2.2.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / illuminate / database / Console / Migrations / MigrateCommand.php
independent-analytics / vendor / illuminate / database / Console / Migrations Last commit date
BaseCommand.php 2 years ago FreshCommand.php 2 years ago InstallCommand.php 2 years ago MigrateCommand.php 2 years ago MigrateMakeCommand.php 2 years ago RefreshCommand.php 2 years ago ResetCommand.php 2 years ago RollbackCommand.php 2 years ago StatusCommand.php 2 years ago TableGuesser.php 2 years ago
MigrateCommand.php
145 lines
1 <?php
2
3 namespace IAWP_SCOPED\Illuminate\Database\Console\Migrations;
4
5 use IAWP_SCOPED\Illuminate\Console\ConfirmableTrait;
6 use IAWP_SCOPED\Illuminate\Contracts\Events\Dispatcher;
7 use IAWP_SCOPED\Illuminate\Database\Events\SchemaLoaded;
8 use IAWP_SCOPED\Illuminate\Database\Migrations\Migrator;
9 use IAWP_SCOPED\Illuminate\Database\SqlServerConnection;
10 /** @internal */
11 class MigrateCommand extends BaseCommand
12 {
13 use ConfirmableTrait;
14 /**
15 * The name and signature of the console command.
16 *
17 * @var string
18 */
19 protected $signature = 'migrate {--database= : The database connection to use}
20 {--force : Force the operation to run when in production}
21 {--path=* : The path(s) to the migrations files to be executed}
22 {--realpath : Indicate any provided migration file paths are pre-resolved absolute paths}
23 {--schema-path= : The path to a schema dump file}
24 {--pretend : Dump the SQL queries that would be run}
25 {--seed : Indicates if the seed task should be re-run}
26 {--seeder= : The class name of the root seeder}
27 {--step : Force the migrations to be run so they can be rolled back individually}';
28 /**
29 * The console command description.
30 *
31 * @var string
32 */
33 protected $description = 'Run the database migrations';
34 /**
35 * The migrator instance.
36 *
37 * @var \Illuminate\Database\Migrations\Migrator
38 */
39 protected $migrator;
40 /**
41 * The event dispatcher instance.
42 *
43 * @var \Illuminate\Contracts\Events\Dispatcher
44 */
45 protected $dispatcher;
46 /**
47 * Create a new migration command instance.
48 *
49 * @param \Illuminate\Database\Migrations\Migrator $migrator
50 * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
51 * @return void
52 */
53 public function __construct(Migrator $migrator, Dispatcher $dispatcher)
54 {
55 parent::__construct();
56 $this->migrator = $migrator;
57 $this->dispatcher = $dispatcher;
58 }
59 /**
60 * Execute the console command.
61 *
62 * @return int
63 */
64 public function handle()
65 {
66 if (!$this->confirmToProceed()) {
67 return 1;
68 }
69 $this->migrator->usingConnection($this->option('database'), function () {
70 $this->prepareDatabase();
71 // Next, we will check to see if a path option has been defined. If it has
72 // we will use the path relative to the root of this installation folder
73 // so that migrations may be run for any path within the applications.
74 $this->migrator->setOutput($this->output)->run($this->getMigrationPaths(), ['pretend' => $this->option('pretend'), 'step' => $this->option('step')]);
75 // Finally, if the "seed" option has been given, we will re-run the database
76 // seed task to re-populate the database, which is convenient when adding
77 // a migration and a seed at the same time, as it is only this command.
78 if ($this->option('seed') && !$this->option('pretend')) {
79 $this->call('db:seed', ['--class' => $this->option('seeder') ?: 'Database\\Seeders\\DatabaseSeeder', '--force' => \true]);
80 }
81 });
82 return 0;
83 }
84 /**
85 * Prepare the migration database for running.
86 *
87 * @return void
88 */
89 protected function prepareDatabase()
90 {
91 if (!$this->migrator->repositoryExists()) {
92 $this->call('migrate:install', \array_filter(['--database' => $this->option('database')]));
93 }
94 if (!$this->migrator->hasRunAnyMigrations() && !$this->option('pretend')) {
95 $this->loadSchemaState();
96 }
97 }
98 /**
99 * Load the schema state to seed the initial database schema structure.
100 *
101 * @return void
102 */
103 protected function loadSchemaState()
104 {
105 $connection = $this->migrator->resolveConnection($this->option('database'));
106 // First, we will make sure that the connection supports schema loading and that
107 // the schema file exists before we proceed any further. If not, we will just
108 // continue with the standard migration operation as normal without errors.
109 if ($connection instanceof SqlServerConnection || !\is_file($path = $this->schemaPath($connection))) {
110 return;
111 }
112 $this->line('<info>Loading stored database schema:</info> ' . $path);
113 $startTime = \microtime(\true);
114 // Since the schema file will create the "migrations" table and reload it to its
115 // proper state, we need to delete it here so we don't get an error that this
116 // table already exists when the stored database schema file gets executed.
117 $this->migrator->deleteRepository();
118 $connection->getSchemaState()->handleOutputUsing(function ($type, $buffer) {
119 $this->output->write($buffer);
120 })->load($path);
121 $runTime = \number_format((\microtime(\true) - $startTime) * 1000, 2);
122 // Finally, we will fire an event that this schema has been loaded so developers
123 // can perform any post schema load tasks that are necessary in listeners for
124 // this event, which may seed the database tables with some necessary data.
125 $this->dispatcher->dispatch(new SchemaLoaded($connection, $path));
126 $this->line('<info>Loaded stored database schema.</info> (' . $runTime . 'ms)');
127 }
128 /**
129 * Get the path to the stored schema for the given connection.
130 *
131 * @param \Illuminate\Database\Connection $connection
132 * @return string
133 */
134 protected function schemaPath($connection)
135 {
136 if ($this->option('schema-path')) {
137 return $this->option('schema-path');
138 }
139 if (\file_exists($path = database_path('schema/' . $connection->getName() . '-schema.dump'))) {
140 return $path;
141 }
142 return database_path('schema/' . $connection->getName() . '-schema.sql');
143 }
144 }
145