Skip to content

Commit

Permalink
enhance upgrade process
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w committed Jul 16, 2024
1 parent a2df564 commit 543f28e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 57 deletions.
3 changes: 2 additions & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
$sql->setQuery('UPDATE ' . rex::getTable('neues_category') . ' SET uuid = uuid() WHERE uuid IS NULL OR uuid = ""');
$sql->setQuery('UPDATE ' . rex::getTable('neues_entry') . ' SET uuid = uuid() WHERE uuid IS NULL OR uuid = ""');

Neues::ensureDbScheme();
require_once __DIR__ . '/install/update_scheme.php';

}

if (!rex_media::get('neues_entry_fallback_image.png')) {
Expand Down
55 changes: 55 additions & 0 deletions install/update_scheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

rex_sql_table::get(rex::getTable('neues_entry'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('status', 'int(11)'))
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('teaser', 'text'))
->ensureColumn(new rex_sql_column('description', 'text'))
->ensureColumn(new rex_sql_column('domain_ids', 'text'))
->ensureColumn(new rex_sql_column('lang_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('publishdate', 'datetime'))
->ensureColumn(new rex_sql_column('author_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('url', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image', 'text'))
->ensureColumn(new rex_sql_column('images', 'text'))
->ensureColumn(new rex_sql_column('createdate', 'datetime'))
->ensureColumn(new rex_sql_column('createuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updatedate', 'datetime'))
->ensureColumn(new rex_sql_column('updateuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensureIndex(new rex_sql_index('uuid', ['uuid'], rex_sql_index::UNIQUE))
->ensureIndex(new rex_sql_index('status', ['status']))
->ensureIndex(new rex_sql_index('publishdate', ['publishdate']))
->ensureIndex(new rex_sql_index('description', ['description'], rex_sql_index::FULLTEXT))
->ensure();

rex_sql_table::get(rex::getTable('neues_category'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image', 'text'))
->ensureColumn(new rex_sql_column('status', 'text'))
->ensureColumn(new rex_sql_column('createuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updateuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updatedate', 'datetime'))
->ensureColumn(new rex_sql_column('createdate', 'datetime'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensureIndex(new rex_sql_index('uuid', ['uuid'], rex_sql_index::UNIQUE))
->ensure();
rex_sql_table::get(rex::getTable('neues_author'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('nickname', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('text', 'text'))
->ensureColumn(new rex_sql_column('be_user_id', 'text'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensure();

rex_sql_table::get(rex::getTable('neues_entry_category_rel'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('entry_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('category_id', 'int(10) unsigned'))
->ensureIndex(new rex_sql_index('entry_id_category_id', ['entry_id', 'category_id'], rex_sql_index::UNIQUE))
->ensure();

?>
55 changes: 0 additions & 55 deletions lib/neues.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,59 +59,4 @@ public static function getEntry(int $postId): string
$fragment->setVar('post', $post);
return $fragment->parse('neues/entry.php');
}

public static function ensureDbScheme()
{
rex_sql_table::get(rex::getTable('neues_entry'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('status', 'int(11)'))
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('teaser', 'text'))
->ensureColumn(new rex_sql_column('description', 'text'))
->ensureColumn(new rex_sql_column('domain_ids', 'text'))
->ensureColumn(new rex_sql_column('lang_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('publishdate', 'datetime'))
->ensureColumn(new rex_sql_column('author_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('url', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image', 'text'))
->ensureColumn(new rex_sql_column('images', 'text'))
->ensureColumn(new rex_sql_column('createdate', 'datetime'))
->ensureColumn(new rex_sql_column('createuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updatedate', 'datetime'))
->ensureColumn(new rex_sql_column('updateuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensureIndex(new rex_sql_index('uuid', ['uuid'], rex_sql_index::UNIQUE))
->ensureIndex(new rex_sql_index('status', ['status']))
->ensureIndex(new rex_sql_index('publishdate', ['publishdate']))
->ensureIndex(new rex_sql_index('description', ['description'], rex_sql_index::FULLTEXT))
->ensure();

rex_sql_table::get(rex::getTable('neues_category'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image', 'text'))
->ensureColumn(new rex_sql_column('status', 'text'))
->ensureColumn(new rex_sql_column('createuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updateuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updatedate', 'datetime'))
->ensureColumn(new rex_sql_column('createdate', 'datetime'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensureIndex(new rex_sql_index('uuid', ['uuid'], rex_sql_index::UNIQUE))
->ensure();
rex_sql_table::get(rex::getTable('neues_author'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('nickname', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('text', 'text'))
->ensureColumn(new rex_sql_column('be_user_id', 'text'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensure();

rex_sql_table::get(rex::getTable('neues_entry_category_rel'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('entry_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('category_id', 'int(10) unsigned'))
->ensureIndex(new rex_sql_index('entry_id_category_id', ['entry_id', 'category_id'], rex_sql_index::UNIQUE))
->ensure();
}
}
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: neues
version: '5.0.0-dev2'
version: '5.0.0-dev1'
author: 'FriendsOfREDAXO, Alexander Walther, Paul Götz, Thorben'
supportpage: https://alexplusde.github.io/neues/
load: late
Expand Down

0 comments on commit 543f28e

Please sign in to comment.