Skip to content

Commit

Permalink
Merge pull request #871 from nextcloud/fix/noid/contexts-db-autoinc
Browse files Browse the repository at this point in the history
fix(DB): ID columns should auto-increment
  • Loading branch information
blizzz authored Feb 26, 2024
2 parents 5f9387d + d5a4578 commit 4c7f6c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Migration/Version000800Date20240213123743.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function shouldAddTable(string $tableName, ISchemaWrapper $schema): ?T
*/
protected function haveContextTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'context', $schema)) {
$table->addColumn('id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('name', Types::STRING, ['notnull' => true, 'length' => 200]);
$table->addColumn('icon', Types::STRING, ['notnull' => true, 'length' => 64]);
$table->addColumn('description', Types::TEXT);
Expand All @@ -81,7 +81,7 @@ protected function haveContextTable(ISchemaWrapper $schema): void {
*/
protected function haveContextNodeRelationTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'rel_context_node', $schema)) {
$table->addColumn('id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('context_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('node_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('node_type', Types::STRING, ['notnull' => true, 'length' => 50]);
Expand All @@ -96,7 +96,7 @@ protected function haveContextNodeRelationTable(ISchemaWrapper $schema): void {
*/
protected function havePageTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'page', $schema)) {
$table->addColumn('id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('context_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('page_type', Types::STRING, ['notnull' => true, 'length' => 32]);

Expand All @@ -109,7 +109,7 @@ protected function havePageTable(ISchemaWrapper $schema): void {
*/
protected function havePageContentTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'page_content', $schema)) {
$table->addColumn('id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('page_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('node_rel_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('order', Types::INTEGER, ['notnull' => true]);
Expand Down

0 comments on commit 4c7f6c2

Please sign in to comment.