public static function chooseMap($table) { //not sure which map so choose it here... $maps[] = DatabaseMigrationMap::getCraigloriousTableMap(); $maps[] = DatabaseMigrationMap::getTenantTableMap(); foreach ($maps as $map) { if (array_key_exists($table, $map['tables'])) { return $map; } } return false; }
public static function makeModels($dbc) { $craiglorious_tables_map = DatabaseMigrationMap::getCraigloriousTableMap(); $tenant_tables_map = DatabaseMigrationMap::getTenantTableMap(); // $test = $tenant_tables_map['tables']['pos_products']; // $tenant_tables_map['tables'] = []; // $tenant_tables_map['tables']['pos_products'] = $test; $modelGenerator = new ModelGenerator(); $tenant_migration_path = self::getModelPath() . '/Tenant'; $modelGenerator->makeModelsFromExistingDatabase($dbc, $tenant_migration_path, $tenant_tables_map); $cg_migration_path = self::getModelPath() . '/Craiglorious'; $modelGenerator->makeModelsFromExistingDatabase($dbc, $cg_migration_path, $craiglorious_tables_map); }
public function importEmbrasseMoiData() { $system = System::where('company', '=', 'Embrasse-Moi')->first(); if (!$system) { dd('did you create company named Embrasse-Moi?'); } $system->createTenantConnection(); echo 'Importing Data From Database: ' . $system->getDBC() . PHP_EOL; $craiglorious_tables_map = DatabaseMigrationMap::getCraigloriousTableMap(); $tenant_tables_map = DatabaseMigrationMap::getTenantTableMap(); // $test = $tenant_tables_map['tables']['pos_accounts']; // $tenant_tables_map['tables'] = []; // $tenant_tables_map['tables']['pos_accounts'] = $test; $this->importTables($this->source_connection, $system->getDBC(), $tenant_tables_map); $this->importTables($this->source_connection, 'craiglorious', $craiglorious_tables_map); }
public static function makeFactories($dbc) { //get the tables to migrate - I am migrating to two different migrations, one for //the main system, one for the tenant system. //You are probably just needing one migration. Re-write the table map for your use. $craiglorious_tables_map = DatabaseMigrationMap::getCraigloriousTableMap(); $tenant_tables_map = DatabaseMigrationMap::getTenantTableMap(); //to test a single table uncomment the lower lines and change pos_product_image_lookup to your //source table // $test = $tenant_tables_map['tables']['pos_product_image_lookup']; // $tenant_tables_map['tables'] = []; // $tenant_tables_map['tables']['pos_product_image_lookup'] = $test; $path = base_path() . '/database/factories'; $path = base_path() . '/database/exports/factories'; $namespace = 'App\\Models'; $factory_generator = new FactoryGenerator(); $tenant_namespace = $namespace . '\\Tenant'; $factory_generator->makeFactoriesFromExistingDatabase($dbc, $path, $tenant_namespace, $tenant_tables_map); }