Passed
Push — master ( 943d95...7bca3d )
by Roeland
27:45 queued 12:08
created
core/Command/Db/ConvertFilecacheBigInt.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -42,91 +42,91 @@
 block discarded – undo
42 42
 
43 43
 class ConvertFilecacheBigInt extends Command {
44 44
 
45
-	/** @var IDBConnection */
46
-	private $connection;
47
-
48
-	/**
49
-	 * @param IDBConnection $connection
50
-	 */
51
-	public function __construct(IDBConnection $connection) {
52
-		$this->connection = $connection;
53
-		parent::__construct();
54
-	}
55
-
56
-	protected function configure() {
57
-		$this
58
-			->setName('db:convert-filecache-bigint')
59
-			->setDescription('Convert the ID columns of the filecache to BigInt');
60
-	}
61
-
62
-	protected function getColumnsByTable() {
63
-		// also update in CheckSetupController::hasBigIntConversionPendingColumns()
64
-		return [
65
-			'activity' => ['activity_id', 'object_id'],
66
-			'activity_mq' => ['mail_id'],
67
-			'authtoken' => ['id'],
68
-			'bruteforce_attempts' => ['id'],
69
-			'federated_reshares' => ['share_id'],
70
-			'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
71
-			'filecache_extended' => ['fileid'],
72
-			'files_trash' => ['auto_id'],
73
-			'file_locks' => ['id'],
74
-			'jobs' => ['id'],
75
-			'mimetypes' => ['id'],
76
-			'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
77
-			'share_external' => ['id', 'parent'],
78
-			'storages' => ['numeric_id'],
79
-		];
80
-	}
81
-
82
-	protected function execute(InputInterface $input, OutputInterface $output): int {
83
-		$schema = new SchemaWrapper($this->connection);
84
-		$isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
85
-		$updates = [];
86
-
87
-		$tables = $this->getColumnsByTable();
88
-		foreach ($tables as $tableName => $columns) {
89
-			if (!$schema->hasTable($tableName)) {
90
-				continue;
91
-			}
92
-
93
-			$table = $schema->getTable($tableName);
94
-
95
-			foreach ($columns as $columnName) {
96
-				$column = $table->getColumn($columnName);
97
-				$isAutoIncrement = $column->getAutoincrement();
98
-				$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
99
-				if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
100
-					$column->setType(Type::getType(Types::BIGINT));
101
-					$column->setOptions(['length' => 20]);
102
-
103
-					$updates[] = '* ' . $tableName . '.' . $columnName;
104
-				}
105
-			}
106
-		}
107
-
108
-		if (empty($updates)) {
109
-			$output->writeln('<info>All tables already up to date!</info>');
110
-			return 0;
111
-		}
112
-
113
-		$output->writeln('<comment>Following columns will be updated:</comment>');
114
-		$output->writeln('');
115
-		$output->writeln($updates);
116
-		$output->writeln('');
117
-		$output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>');
118
-
119
-		if ($input->isInteractive()) {
120
-			$helper = $this->getHelper('question');
121
-			$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
122
-
123
-			if (!$helper->ask($input, $output, $question)) {
124
-				return 1;
125
-			}
126
-		}
127
-
128
-		$this->connection->migrateToSchema($schema->getWrappedSchema());
129
-
130
-		return 0;
131
-	}
45
+    /** @var IDBConnection */
46
+    private $connection;
47
+
48
+    /**
49
+     * @param IDBConnection $connection
50
+     */
51
+    public function __construct(IDBConnection $connection) {
52
+        $this->connection = $connection;
53
+        parent::__construct();
54
+    }
55
+
56
+    protected function configure() {
57
+        $this
58
+            ->setName('db:convert-filecache-bigint')
59
+            ->setDescription('Convert the ID columns of the filecache to BigInt');
60
+    }
61
+
62
+    protected function getColumnsByTable() {
63
+        // also update in CheckSetupController::hasBigIntConversionPendingColumns()
64
+        return [
65
+            'activity' => ['activity_id', 'object_id'],
66
+            'activity_mq' => ['mail_id'],
67
+            'authtoken' => ['id'],
68
+            'bruteforce_attempts' => ['id'],
69
+            'federated_reshares' => ['share_id'],
70
+            'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
71
+            'filecache_extended' => ['fileid'],
72
+            'files_trash' => ['auto_id'],
73
+            'file_locks' => ['id'],
74
+            'jobs' => ['id'],
75
+            'mimetypes' => ['id'],
76
+            'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
77
+            'share_external' => ['id', 'parent'],
78
+            'storages' => ['numeric_id'],
79
+        ];
80
+    }
81
+
82
+    protected function execute(InputInterface $input, OutputInterface $output): int {
83
+        $schema = new SchemaWrapper($this->connection);
84
+        $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
85
+        $updates = [];
86
+
87
+        $tables = $this->getColumnsByTable();
88
+        foreach ($tables as $tableName => $columns) {
89
+            if (!$schema->hasTable($tableName)) {
90
+                continue;
91
+            }
92
+
93
+            $table = $schema->getTable($tableName);
94
+
95
+            foreach ($columns as $columnName) {
96
+                $column = $table->getColumn($columnName);
97
+                $isAutoIncrement = $column->getAutoincrement();
98
+                $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
99
+                if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
100
+                    $column->setType(Type::getType(Types::BIGINT));
101
+                    $column->setOptions(['length' => 20]);
102
+
103
+                    $updates[] = '* ' . $tableName . '.' . $columnName;
104
+                }
105
+            }
106
+        }
107
+
108
+        if (empty($updates)) {
109
+            $output->writeln('<info>All tables already up to date!</info>');
110
+            return 0;
111
+        }
112
+
113
+        $output->writeln('<comment>Following columns will be updated:</comment>');
114
+        $output->writeln('');
115
+        $output->writeln($updates);
116
+        $output->writeln('');
117
+        $output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>');
118
+
119
+        if ($input->isInteractive()) {
120
+            $helper = $this->getHelper('question');
121
+            $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
122
+
123
+            if (!$helper->ask($input, $output, $question)) {
124
+                return 1;
125
+            }
126
+        }
127
+
128
+        $this->connection->migrateToSchema($schema->getWrappedSchema());
129
+
130
+        return 0;
131
+    }
132 132
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Migration/Version1010Date20200630192639.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -33,55 +33,55 @@
 block discarded – undo
33 33
 use OCP\Migration\SimpleMigrationStep;
34 34
 
35 35
 class Version1010Date20200630192639 extends SimpleMigrationStep {
36
-	/**
37
-	 * @param IOutput $output
38
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
-	 * @param array $options
40
-	 * @return null|ISchemaWrapper
41
-	 */
42
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
43
-		/** @var ISchemaWrapper $schema */
44
-		$schema = $schemaClosure();
36
+    /**
37
+     * @param IOutput $output
38
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
+     * @param array $options
40
+     * @return null|ISchemaWrapper
41
+     */
42
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
43
+        /** @var ISchemaWrapper $schema */
44
+        $schema = $schemaClosure();
45 45
 
46
-		if (!$schema->hasTable('files_trash')) {
47
-			$table = $schema->createTable('files_trash');
48
-			$table->addColumn('auto_id', Types::BIGINT, [
49
-				'autoincrement' => true,
50
-				'notnull' => true,
51
-			]);
52
-			$table->addColumn('id', Types::STRING, [
53
-				'notnull' => true,
54
-				'length' => 250,
55
-				'default' => '',
56
-			]);
57
-			$table->addColumn('user', Types::STRING, [
58
-				'notnull' => true,
59
-				'length' => 64,
60
-				'default' => '',
61
-			]);
62
-			$table->addColumn('timestamp', Types::STRING, [
63
-				'notnull' => true,
64
-				'length' => 12,
65
-				'default' => '',
66
-			]);
67
-			$table->addColumn('location', Types::STRING, [
68
-				'notnull' => true,
69
-				'length' => 512,
70
-				'default' => '',
71
-			]);
72
-			$table->addColumn('type', Types::STRING, [
73
-				'notnull' => false,
74
-				'length' => 4,
75
-			]);
76
-			$table->addColumn('mime', Types::STRING, [
77
-				'notnull' => false,
78
-				'length' => 255,
79
-			]);
80
-			$table->setPrimaryKey(['auto_id']);
81
-			$table->addIndex(['id'], 'id_index');
82
-			$table->addIndex(['timestamp'], 'timestamp_index');
83
-			$table->addIndex(['user'], 'user_index');
84
-		}
85
-		return $schema;
86
-	}
46
+        if (!$schema->hasTable('files_trash')) {
47
+            $table = $schema->createTable('files_trash');
48
+            $table->addColumn('auto_id', Types::BIGINT, [
49
+                'autoincrement' => true,
50
+                'notnull' => true,
51
+            ]);
52
+            $table->addColumn('id', Types::STRING, [
53
+                'notnull' => true,
54
+                'length' => 250,
55
+                'default' => '',
56
+            ]);
57
+            $table->addColumn('user', Types::STRING, [
58
+                'notnull' => true,
59
+                'length' => 64,
60
+                'default' => '',
61
+            ]);
62
+            $table->addColumn('timestamp', Types::STRING, [
63
+                'notnull' => true,
64
+                'length' => 12,
65
+                'default' => '',
66
+            ]);
67
+            $table->addColumn('location', Types::STRING, [
68
+                'notnull' => true,
69
+                'length' => 512,
70
+                'default' => '',
71
+            ]);
72
+            $table->addColumn('type', Types::STRING, [
73
+                'notnull' => false,
74
+                'length' => 4,
75
+            ]);
76
+            $table->addColumn('mime', Types::STRING, [
77
+                'notnull' => false,
78
+                'length' => 255,
79
+            ]);
80
+            $table->setPrimaryKey(['auto_id']);
81
+            $table->addIndex(['id'], 'id_index');
82
+            $table->addIndex(['timestamp'], 'timestamp_index');
83
+            $table->addIndex(['user'], 'user_index');
84
+        }
85
+        return $schema;
86
+    }
87 87
 }
Please login to merge, or discard this patch.