/**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Project::created(function (Project $project) {
         PGSchema::create($project->schema_name);
         PGSchema::migrate($project->schema_name, ["--path" => "eddie/database/migations/schemamigrations"]);
     });
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Project::deleting(function (Project $project) {
         PGSchema::switchTo();
         PGSchema::drop($project->schema_name);
     });
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('Starting migration:');
     $this->line('');
     // Retrieve tenants from db
     $tenants = DB::select('SELECT n.nspname AS "name", pg_catalog.pg_get_userbyid(n.nspowner) AS "owner", pg_catalog.array_to_string(n.nspacl, E\'\\n\') AS "access_privileges", pg_catalog.obj_description(n.oid, \'pg_namespace\') AS "description" FROM pg_catalog.pg_namespace n WHERE n.nspname !~ \'^pg_\' AND n.nspname <> \'information_schema\' ORDER BY 1');
     $this->line(' -> ' . count($tenants) . ' schemas to migrate.');
     $bar = $this->output->createProgressBar(count($tenants));
     // Migrate all tenants schemas
     foreach ($tenants as $tenant) {
         PGSchema::migrate($tenant->name, ['--path' => 'database/migrations']);
         $bar->advance();
     }
     $bar->finish();
     $this->line('');
     $this->line('');
     $this->info('Migration finished!');
 }
Beispiel #4
0
 /**
  * Switch to the newly created schema.
  *
  * @param $project
  *
  */
 public function tearDown()
 {
     \Pacuna\Schemas\Facades\PGSchema::switchTo($this->testSchemaName);
 }