Completed
Push — master ( 452e96...4154a5 )
by Morris
61:46 queued 43:18
created
core/Command/Db/ConvertFilecacheBigInt.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -33,75 +33,75 @@
 block discarded – undo
33 33
 
34 34
 class ConvertFilecacheBigInt extends Command {
35 35
 
36
-	/** @var IDBConnection */
37
-	private $connection;
38
-
39
-	/**
40
-	 * @param IDBConnection $connection
41
-	 */
42
-	public function __construct(IDBConnection $connection) {
43
-		$this->connection = $connection;
44
-		parent::__construct();
45
-	}
46
-
47
-	protected function configure() {
48
-		$this
49
-			->setName('db:convert-filecache-bigint')
50
-			->setDescription('Convert the ID columns of the filecache to BigInt');
51
-	}
52
-
53
-	protected function getColumnsByTable() {
54
-		return [
55
-			'activity' => ['activity_id', 'object_id'],
56
-			'activity_mq' => ['mail_id'],
57
-			'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
58
-			'mimetypes' => ['id'],
59
-			'storages' => ['numeric_id'],
60
-		];
61
-	}
62
-
63
-	protected function execute(InputInterface $input, OutputInterface $output) {
64
-
65
-		$schema = new SchemaWrapper($this->connection);
66
-		$updates = [];
67
-
68
-		$tables = $this->getColumnsByTable();
69
-		foreach ($tables as $tableName => $columns) {
70
-			if (!$schema->hasTable($tableName)) {
71
-				continue;
72
-			}
73
-
74
-			$table = $schema->getTable($tableName);
75
-
76
-			foreach ($columns as $columnName) {
77
-				$column = $table->getColumn($columnName);
78
-				if ($column->getType()->getName() !== Type::BIGINT) {
79
-					$column->setType(Type::getType(Type::BIGINT));
80
-					$column->setOptions(['length' => 20]);
81
-
82
-					$updates[] = $tableName . '.' . $columnName;
83
-				}
84
-			}
85
-		}
86
-
87
-		if (empty($updates)) {
88
-			$output->writeln('<info>All tables already up to date!</info>');
89
-			return 0;
90
-		}
91
-
92
-		$output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>');
93
-
94
-		if ($input->isInteractive()) {
95
-			$helper = $this->getHelper('question');
96
-			$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
97
-
98
-			if (!$helper->ask($input, $output, $question)) {
99
-				return 1;
100
-			}
101
-		}
102
-
103
-		$this->connection->migrateToSchema($schema->getWrappedSchema());
104
-
105
-		return 0;
106
-	}
36
+    /** @var IDBConnection */
37
+    private $connection;
38
+
39
+    /**
40
+     * @param IDBConnection $connection
41
+     */
42
+    public function __construct(IDBConnection $connection) {
43
+        $this->connection = $connection;
44
+        parent::__construct();
45
+    }
46
+
47
+    protected function configure() {
48
+        $this
49
+            ->setName('db:convert-filecache-bigint')
50
+            ->setDescription('Convert the ID columns of the filecache to BigInt');
51
+    }
52
+
53
+    protected function getColumnsByTable() {
54
+        return [
55
+            'activity' => ['activity_id', 'object_id'],
56
+            'activity_mq' => ['mail_id'],
57
+            'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
58
+            'mimetypes' => ['id'],
59
+            'storages' => ['numeric_id'],
60
+        ];
61
+    }
62
+
63
+    protected function execute(InputInterface $input, OutputInterface $output) {
64
+
65
+        $schema = new SchemaWrapper($this->connection);
66
+        $updates = [];
67
+
68
+        $tables = $this->getColumnsByTable();
69
+        foreach ($tables as $tableName => $columns) {
70
+            if (!$schema->hasTable($tableName)) {
71
+                continue;
72
+            }
73
+
74
+            $table = $schema->getTable($tableName);
75
+
76
+            foreach ($columns as $columnName) {
77
+                $column = $table->getColumn($columnName);
78
+                if ($column->getType()->getName() !== Type::BIGINT) {
79
+                    $column->setType(Type::getType(Type::BIGINT));
80
+                    $column->setOptions(['length' => 20]);
81
+
82
+                    $updates[] = $tableName . '.' . $columnName;
83
+                }
84
+            }
85
+        }
86
+
87
+        if (empty($updates)) {
88
+            $output->writeln('<info>All tables already up to date!</info>');
89
+            return 0;
90
+        }
91
+
92
+        $output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>');
93
+
94
+        if ($input->isInteractive()) {
95
+            $helper = $this->getHelper('question');
96
+            $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
97
+
98
+            if (!$helper->ask($input, $output, $question)) {
99
+                return 1;
100
+            }
101
+        }
102
+
103
+        $this->connection->migrateToSchema($schema->getWrappedSchema());
104
+
105
+        return 0;
106
+    }
107 107
 }
Please login to merge, or discard this patch.