From 2078096ba668405fac2312431dbc7fd0dc08b8df Mon Sep 17 00:00:00 2001 From: Alfred Egger Date: Wed, 16 Dec 2020 21:38:03 +0100 Subject: [PATCH] Migrate away from database.xml to new database migrations --- appinfo/database.xml | 268 ------------------ .../Version020109Date20201216203338.php | 173 +++++++++++ 2 files changed, 173 insertions(+), 268 deletions(-) delete mode 100644 appinfo/database.xml create mode 100644 lib/migration/Version020109Date20201216203338.php diff --git a/appinfo/database.xml b/appinfo/database.xml deleted file mode 100644 index dd63cc9..0000000 --- a/appinfo/database.xml +++ /dev/null @@ -1,268 +0,0 @@ - - - *dbname* - true - false - utf8 - - - *dbprefix*ocsms_user_datas - - - user_id - text - true - 64 - - - datakey - text - true - 64 - - - datavalue - text - 64 - true - - - user_datas_user_datakey - - user_id - - - datakey - - - -
- - *dbprefix*ocsms_smsdatas - - - id - integer - 0 - true - 1 - 10 - true - - - user_id - text - true - 64 - - - added - timestamp - true - 1970-01-01 00:00:00 - - - lastmodified - timestamp - true - 1970-01-01 00:00:00 - - - sms_id - integer - true - 5 - - - sms_address - text - true - 512 - - - sms_msg - text - true - 10240 - - - sms_date - integer - true - 10 - - - sms_flags - text - true - 00 - 2 - - - sms_mailbox - integer - true - 1 - - - sms_type - integer - true - 1 - - - smsdata_user_mailbox - - user_id - - - sms_mailbox - - - - smsdata_user_smsid - - user_id - - - sms_id - - - - smsdata_user_mailbox_date - - user_id - - - sms_mailbox - - - sms_date - - - - smsdata_user_mailbox_address - - user_id - - - sms_mailbox - - - sms_address - - - - smsdata_user_mailbox_address_date - - user_id - - - sms_mailbox - - - sms_address - - - sms_date - - - -
- - *dbprefix*ocsms_sendmessage_queue - - - id - integer - 0 - true - 1 - 10 - true - - - user_id - text - true - 64 - - - sms_address - text - true - 64 - - - sms_msg - text - true - 2048 - - -
- - *dbprefix*ocsms_conversation_read_states - - - user_id - text - true - 64 - - - phone_number - text - true - 64 - - - int_date - integer - 32 - true - - - sms_conversation_rs_pkey - - user_id - - - phone_number - - - -
- - *dbprefix*ocsms_config - - - user - text - true - 255 - - - key - text - true - 255 - - - value - text - false - 10240 - - - config_user_key - - user - - - key - - - -
-
diff --git a/lib/migration/Version020109Date20201216203338.php b/lib/migration/Version020109Date20201216203338.php new file mode 100644 index 0000000..e78b11a --- /dev/null +++ b/lib/migration/Version020109Date20201216203338.php @@ -0,0 +1,173 @@ +hasTable('ocsms_user_datas')) { + $table = $schema->createTable('ocsms_user_datas'); + $table->addColumn('user_id', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('datakey', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('datavalue', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addIndex(['user_id', 'datakey'], 'user_datas_user_datakey'); + } + + if (!$schema->hasTable('ocsms_smsdatas')) { + $table = $schema->createTable('ocsms_smsdatas'); + $table->addColumn('id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 10, + ]); + $table->addColumn('user_id', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('added', 'datetime', [ + 'notnull' => true, + 'default' => '1970-01-01 00:00:00', + ]); + $table->addColumn('lastmodified', 'datetime', [ + 'notnull' => true, + 'default' => '1970-01-01 00:00:00', + ]); + $table->addColumn('sms_id', 'bigint', [ + 'notnull' => true, + 'length' => 5, + ]); + $table->addColumn('sms_address', 'string', [ + 'notnull' => true, + 'length' => 512, + ]); + $table->addColumn('sms_msg', 'string', [ + 'notnull' => true, + 'length' => 10240, + ]); + $table->addColumn('sms_date', 'bigint', [ + 'notnull' => true, + 'length' => 10, + ]); + $table->addColumn('sms_flags', 'string', [ + 'notnull' => true, + 'length' => 2, + 'default' => '00', + ]); + $table->addColumn('sms_mailbox', 'smallint', [ + 'notnull' => true, + 'length' => 1, + ]); + $table->addColumn('sms_type', 'smallint', [ + 'notnull' => true, + 'length' => 1, + ]); + $table->setPrimaryKey(['id']); + $table->addIndex(['user_id', 'sms_mailbox'], 'smsdata_user_mailbox'); + $table->addIndex(['user_id', 'sms_id'], 'smsdata_user_smsid'); + $table->addIndex(['user_id', 'sms_mailbox', 'sms_date'], 'smsdata_user_mailbox_date'); + $table->addIndex(['user_id', 'sms_mailbox', 'sms_address'], 'smsdata_user_mailbox_address'); + $table->addIndex(['user_id', 'sms_mailbox', 'sms_address', 'sms_date'], 'smsdata_user_mailbox_address_date'); + } + + if (!$schema->hasTable('ocsms_sendmessage_queue')) { + $table = $schema->createTable('ocsms_sendmessage_queue'); + $table->addColumn('id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 10, + ]); + $table->addColumn('user_id', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('sms_address', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('sms_msg', 'string', [ + 'notnull' => true, + 'length' => 2048, + ]); + $table->setPrimaryKey(['id']); + } + + if (!$schema->hasTable('ocsms_conversation_read_states')) { + $table = $schema->createTable('ocsms_conversation_read_states'); + $table->addColumn('user_id', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('phone_number', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('int_date', 'bigint', [ + 'notnull' => true, + 'length' => 32, + ]); + $table->addIndex(['user_id', 'phone_number'], 'sms_conversation_rs_pkey'); + } + + if (!$schema->hasTable('ocsms_config')) { + $table = $schema->createTable('ocsms_config'); + $table->addColumn('user', 'string', [ + 'notnull' => true, + 'length' => 255, + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 255, + ]); + $table->addColumn('value', 'string', [ + 'notnull' => false, + 'length' => 10240, + ]); + $table->addIndex(['user', 'key'], 'config_user_key'); + } + return $schema; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { + } +}