| @@ 102-116 (lines=15) @@ | ||
| 99 | * @param $table |
|
| 100 | * @param FieldType $type |
|
| 101 | */ |
|
| 102 | public function dropColumn($table, FieldType $type) |
|
| 103 | { |
|
| 104 | $schema = $type->getSchema(); |
|
| 105 | ||
| 106 | if (!$this->schema->hasTable($table)) { |
|
| 107 | return; |
|
| 108 | } |
|
| 109 | ||
| 110 | $this->schema->table( |
|
| 111 | $table, |
|
| 112 | function (Blueprint $table) use ($schema) { |
|
| 113 | $schema->dropColumn($table); |
|
| 114 | } |
|
| 115 | ); |
|
| 116 | } |
|
| 117 | ||
| 118 | /** |
|
| 119 | * Backup a column's data. |
|
| @@ 124-138 (lines=15) @@ | ||
| 121 | * @param $table |
|
| 122 | * @param FieldType $type |
|
| 123 | */ |
|
| 124 | public function backupColumn($table, FieldType $type) |
|
| 125 | { |
|
| 126 | if (!$this->schema->hasTable($table)) { |
|
| 127 | return; |
|
| 128 | } |
|
| 129 | ||
| 130 | $schema = $type->getSchema(); |
|
| 131 | ||
| 132 | $this->schema->table( |
|
| 133 | $table, |
|
| 134 | function (Blueprint $table) use ($schema) { |
|
| 135 | $schema->backupColumn($table); |
|
| 136 | } |
|
| 137 | ); |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * Restore a column's data. |
|
| @@ 146-160 (lines=15) @@ | ||
| 143 | * @param $table |
|
| 144 | * @param FieldType $type |
|
| 145 | */ |
|
| 146 | public function restoreColumn($table, FieldType $type) |
|
| 147 | { |
|
| 148 | if (!$this->schema->hasTable($table)) { |
|
| 149 | return; |
|
| 150 | } |
|
| 151 | ||
| 152 | $schema = $type->getSchema(); |
|
| 153 | ||
| 154 | $this->schema->table( |
|
| 155 | $table, |
|
| 156 | function (Blueprint $table) use ($schema) { |
|
| 157 | $schema->restoreColumn($table); |
|
| 158 | } |
|
| 159 | ); |
|
| 160 | } |
|
| 161 | } |
|
| 162 | ||