@@ 22-49 (lines=28) @@ | ||
19 | * |
|
20 | * @return void |
|
21 | */ |
|
22 | public function up() |
|
23 | { |
|
24 | /* @var StreamInterface $stream */ |
|
25 | foreach ($this->streams()->all() as $stream) { |
|
26 | ||
27 | if ($this->schema()->hasColumn($stream->getEntryTableName(), 'created_by')) { |
|
28 | ||
29 | $this->schema()->table( |
|
30 | $stream->getEntryTableName(), |
|
31 | function (Blueprint $table) { |
|
32 | $table->renameColumn('created_by', 'created_by_id'); |
|
33 | $table->renameColumn('updated_by', 'updated_by_id'); |
|
34 | } |
|
35 | ); |
|
36 | ||
37 | if ($stream->isTranslatable()) { |
|
38 | ||
39 | $this->schema()->table( |
|
40 | $stream->getEntryTranslationsTableName(), |
|
41 | function (Blueprint $table) { |
|
42 | $table->renameColumn('created_by', 'created_by_id'); |
|
43 | $table->renameColumn('updated_by', 'updated_by_id'); |
|
44 | } |
|
45 | ); |
|
46 | } |
|
47 | } |
|
48 | } |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * Reverse the migrations. |
|
@@ 56-83 (lines=28) @@ | ||
53 | * |
|
54 | * @return void |
|
55 | */ |
|
56 | public function down() |
|
57 | { |
|
58 | /* @var StreamInterface $stream */ |
|
59 | foreach ($this->streams()->all() as $stream) { |
|
60 | ||
61 | if ($this->schema()->hasColumn($stream->getEntryTableName(), 'created_by_id')) { |
|
62 | ||
63 | $this->schema()->table( |
|
64 | $stream->getEntryTableName(), |
|
65 | function (Blueprint $table) { |
|
66 | $table->renameColumn('created_by_id', 'created_by'); |
|
67 | $table->renameColumn('updated_by_id', 'updated_by'); |
|
68 | } |
|
69 | ); |
|
70 | ||
71 | if ($stream->isTranslatable()) { |
|
72 | ||
73 | $this->schema()->table( |
|
74 | $stream->getEntryTranslationsTableName(), |
|
75 | function (Blueprint $table) { |
|
76 | $table->renameColumn('created_by_id', 'created_by'); |
|
77 | $table->renameColumn('updated_by_id', 'updated_by'); |
|
78 | } |
|
79 | ); |
|
80 | } |
|
81 | } |
|
82 | } |
|
83 | } |
|
84 | } |
|
85 |