@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | $schema = $this->compile(); |
| 74 | 74 | $absolutePath = Config::get('db-exporter.export_path.migrations'); |
| 75 | 75 | $this->makePath($absolutePath); |
| 76 | - $this->filename = date('Y_m_d_His').'_create_'.$this->database.'_database.php'; |
|
| 77 | - static::$filePath = $absolutePath."/{$this->filename}"; |
|
| 76 | + $this->filename = date('Y_m_d_His') . '_create_' . $this->database . '_database.php'; |
|
| 77 | + static::$filePath = $absolutePath . "/{$this->filename}"; |
|
| 78 | 78 | file_put_contents(static::$filePath, $schema); |
| 79 | 79 | |
| 80 | 80 | return static::$filePath; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $down = "Schema::drop('{$value['table_name']}');"; |
| 110 | - $up = "Schema::create('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
| 110 | + $up = "Schema::create('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
| 111 | 111 | |
| 112 | 112 | $tableDescribes = $this->getTableDescribes($value['table_name']); |
| 113 | 113 | // Loop over the tables fields |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | if (in_array($type, ['var', 'varchar', 'enum', 'decimal', 'float'])) { |
| 124 | 124 | $para = strpos($values->Type, '('); |
| 125 | 125 | $opt = substr($values->Type, ($para + 1), -1); |
| 126 | - $numbers = $type == 'enum' ? ', array('.$opt.')' : ', '.$opt; |
|
| 126 | + $numbers = $type == 'enum' ? ', array(' . $opt . ')' : ', ' . $opt; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $method = $this->columnType($type); |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $method = 'increments'; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $up .= ' $'."table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
| 134 | + $up .= ' $' . "table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
| 135 | 135 | }//end foreach |
| 136 | 136 | |
| 137 | 137 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
| 138 | 138 | if (!is_null($tableIndexes) && count($tableIndexes)) { |
| 139 | 139 | foreach ($tableIndexes as $index) { |
| 140 | 140 | if (Str::endsWith($index['Key_name'], '_index')) { |
| 141 | - $up .= ' $'."table->index('".$index['Column_name']."');\n"; |
|
| 141 | + $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
| 152 | 152 | if (!is_null($tableConstraints) && count($tableConstraints)) { |
| 153 | 153 | $Constraint = $ConstraintDown = " |
| 154 | - Schema::table('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
| 154 | + Schema::table('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
| 155 | 155 | $tables = []; |
| 156 | 156 | foreach ($tableConstraints as $foreign) { |
| 157 | 157 | if (!in_array($foreign->Field, $tables)) { |
| 158 | - $ConstraintDown .= ' $'."table->dropForeign('".$foreign->Field."');\n"; |
|
| 159 | - $Constraint .= ' $'."table->foreign('".$foreign->Field."')->references('".$foreign->References."')->on('".$foreign->ON."')->onDelete('".$foreign->onDelete."');\n"; |
|
| 158 | + $ConstraintDown .= ' $' . "table->dropForeign('" . $foreign->Field . "');\n"; |
|
| 159 | + $Constraint .= ' $' . "table->foreign('" . $foreign->Field . "')->references('" . $foreign->References . "')->on('" . $foreign->ON . "')->onDelete('" . $foreign->onDelete . "');\n"; |
|
| 160 | 160 | $tables[$foreign->Field] = $foreign->Field; |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | continue; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $upSchema .= " |
|
| 209 | + $upSchema .= " |
|
| 210 | 210 | /** |
| 211 | 211 | * Migration schema for table {$name} |
| 212 | 212 | * |
@@ -223,10 +223,10 @@ discard block |
||
| 223 | 223 | }//end if |
| 224 | 224 | |
| 225 | 225 | // Grab the template |
| 226 | - $template = File::get(__DIR__.'/stubs/migration.stub'); |
|
| 226 | + $template = File::get(__DIR__ . '/stubs/migration.stub'); |
|
| 227 | 227 | |
| 228 | 228 | // Replace the classname |
| 229 | - $template = str_replace('{{name}}', 'Create'.ucfirst(Str::camel($this->database)).'Database', $template); |
|
| 229 | + $template = str_replace('{{name}}', 'Create' . ucfirst(Str::camel($this->database)) . 'Database', $template); |
|
| 230 | 230 | |
| 231 | 231 | // Replace the up and down values |
| 232 | 232 | $template = str_replace('{{up}}', $upSchema, $template); |
@@ -15,25 +15,25 @@ discard block |
||
| 15 | 15 | * @var string |
| 16 | 16 | **/ |
| 17 | 17 | protected $columns = [ |
| 18 | - 'int' => 'integer', |
|
| 19 | - 'smallint' => 'smallInteger', |
|
| 20 | - 'bigint' => 'bigInteger', |
|
| 21 | - 'char ' => 'string', |
|
| 22 | - 'varchar' => 'string', |
|
| 23 | - 'float' => 'float', |
|
| 24 | - 'double' => 'double', |
|
| 25 | - 'decimal' => 'decimal', |
|
| 26 | - 'tinyint' => 'boolean', |
|
| 27 | - 'date' => 'date', |
|
| 28 | - 'timestamp' => 'timestamp', |
|
| 29 | - 'datetime' => 'dateTime', |
|
| 30 | - 'longtext' => 'longText', |
|
| 31 | - 'mediumtext' => 'mediumText', |
|
| 32 | - 'text' => 'text', |
|
| 33 | - 'longblob' => 'binary', |
|
| 34 | - 'blob' => 'binary', |
|
| 35 | - 'enum' => 'enum', |
|
| 36 | - ]; |
|
| 18 | + 'int' => 'integer', |
|
| 19 | + 'smallint' => 'smallInteger', |
|
| 20 | + 'bigint' => 'bigInteger', |
|
| 21 | + 'char ' => 'string', |
|
| 22 | + 'varchar' => 'string', |
|
| 23 | + 'float' => 'float', |
|
| 24 | + 'double' => 'double', |
|
| 25 | + 'decimal' => 'decimal', |
|
| 26 | + 'tinyint' => 'boolean', |
|
| 27 | + 'date' => 'date', |
|
| 28 | + 'timestamp' => 'timestamp', |
|
| 29 | + 'datetime' => 'dateTime', |
|
| 30 | + 'longtext' => 'longText', |
|
| 31 | + 'mediumtext' => 'mediumText', |
|
| 32 | + 'text' => 'text', |
|
| 33 | + 'longblob' => 'binary', |
|
| 34 | + 'blob' => 'binary', |
|
| 35 | + 'enum' => 'enum', |
|
| 36 | + ]; |
|
| 37 | 37 | |
| 38 | 38 | protected $schema; |
| 39 | 39 | |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $this->schema[$value['table_name']] = array( |
| 175 | - 'up' => $up, |
|
| 176 | - 'constraint' => $Constraint, |
|
| 177 | - 'constraint_down' => $ConstraintDown, |
|
| 178 | - 'down' => $down, |
|
| 179 | - ); |
|
| 175 | + 'up' => $up, |
|
| 176 | + 'constraint' => $Constraint, |
|
| 177 | + 'constraint_down' => $ConstraintDown, |
|
| 178 | + 'down' => $down, |
|
| 179 | + ); |
|
| 180 | 180 | }//end foreach |
| 181 | 181 | |
| 182 | 182 | return $this; |
@@ -27,27 +27,27 @@ |
||
| 27 | 27 | * @var array |
| 28 | 28 | **/ |
| 29 | 29 | protected $selects = array( |
| 30 | - 'column_name as Field', |
|
| 31 | - 'column_type as Type', |
|
| 32 | - 'is_nullable as null', |
|
| 33 | - 'column_key as Key', |
|
| 34 | - 'column_default as Default', |
|
| 35 | - 'extra as Extra', |
|
| 36 | - 'data_type as Data_Type', |
|
| 37 | - ); |
|
| 30 | + 'column_name as Field', |
|
| 31 | + 'column_type as Type', |
|
| 32 | + 'is_nullable as null', |
|
| 33 | + 'column_key as Key', |
|
| 34 | + 'column_default as Default', |
|
| 35 | + 'extra as Extra', |
|
| 36 | + 'data_type as Data_Type', |
|
| 37 | + ); |
|
| 38 | 38 | /** |
| 39 | 39 | * Select fields from constraints. |
| 40 | 40 | * |
| 41 | 41 | * @var array |
| 42 | 42 | **/ |
| 43 | 43 | protected $constraints = array( |
| 44 | - 'key_column_usage.table_name as Table', |
|
| 45 | - 'key_column_usage.column_name as Field', |
|
| 46 | - 'key_column_usage.referenced_table_name as ON', |
|
| 47 | - 'key_column_usage.referenced_column_name as References', |
|
| 48 | - 'REFERENTIAL_CONSTRAINTS.UPDATE_RULE as onUpdate', |
|
| 49 | - 'REFERENTIAL_CONSTRAINTS.DELETE_RULE as onDelete', |
|
| 50 | - ); |
|
| 44 | + 'key_column_usage.table_name as Table', |
|
| 45 | + 'key_column_usage.column_name as Field', |
|
| 46 | + 'key_column_usage.referenced_table_name as ON', |
|
| 47 | + 'key_column_usage.referenced_column_name as References', |
|
| 48 | + 'REFERENTIAL_CONSTRAINTS.UPDATE_RULE as onUpdate', |
|
| 49 | + 'REFERENTIAL_CONSTRAINTS.DELETE_RULE as onDelete', |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | 52 | protected function getTables() |
| 53 | 53 | { |