Browse Source

Remove SQLite support (comment out some code + remove some)

Fix migrations for MySQL
Update CHANGELOG
pull/853/head
Timothée Jaussoin 6 years ago
parent
commit
577bb5c409
  1. 2
      CHANGELOG.md
  2. 5
      config/db.example.inc.php
  3. 5
      database/migrations/20190324190611_create_reactions_table.php
  4. 20
      database/migrations/20190625074929_change_href_type_attachements_table.php
  5. 4
      src/Movim/Bootstrap.php
  6. 8
      src/Movim/Migration.php

2
CHANGELOG.md

@ -14,6 +14,8 @@ v0.15 (trunk)
* Add support of XEP-0367: Message Attaching, add Reactions feature in Movim
* Move the index.php file to the public/ subfolder and all the assets bellow it
* Add Snap widget to quickly take pictures and publish them in Chats or Posts
* Refactor the notification mechanism for the Chat (move the status to the messages table)
* Comment and remove SQLite support in the project
v0.14.1
---------------------------

5
config/db.example.inc.php

@ -1,9 +1,8 @@
<?php
# This is the database configuration of Movim
# You need to copy an rename this file to 'db.inc.php' and complete the values
# If using SQLite, only 'type' and 'database' are needed
$conf = [
# The type can be 'pgsql', 'mysql', or 'sqlite'
# The type can be 'pgsql' or 'mysql'
'type' => 'mysql',
# The database username
'username' => 'username',
@ -13,6 +12,6 @@ $conf = [
'host' => 'localhost',
# The port number, 3306 for MySQL and 5432 for PostgreSQL
'port' => 3306,
# The database name, or for SQLite the absolute file path
# The database name
'database' => 'movim'
];

5
database/migrations/20190324190611_create_reactions_table.php

@ -9,8 +9,13 @@ class CreateReactionsTable extends Migration
{
$this->disableForeignKeyCheck();
$this->schema->table('messages', function (Blueprint $table) {
$table->dropForeign(['user_id']);
$table->dropPrimary('messages_pkey');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
});
$this->schema->table('messages', function (Blueprint $table) {

20
database/migrations/20190625074929_change_href_type_attachements_table.php

@ -7,15 +7,23 @@ class ChangeHrefTypeAttachementsTable extends Migration
{
public function up()
{
$this->schema->table('attachments', function (Blueprint $table) {
$table->text('href')->change();
});
/**
* This migration will only works on PosgreSQL, MySQL doesn't suppport indexes on TEXT
* see https://techjourney.net/mysql-error-1170-42000-blobtext-column-used-in-key-specification-without-a-key-length/
*/
if ($this->schema->getConnection()->getDriverName() == 'pgsql') {
$this->schema->table('attachments', function (Blueprint $table) {
$table->text('href')->change();
});
}
}
public function down()
{
$this->schema->table('attachments', function (Blueprint $table) {
$table->string('href', 512)->change();
});
if ($this->schema->getConnection()->getDriverName() == 'pgsql') {
$this->schema->table('attachments', function (Blueprint $table) {
$table->string('href', 512)->change();
});
}
}
}

4
src/Movim/Bootstrap.php

@ -173,14 +173,14 @@ class Bootstrap
$capsule->setAsGlobal();
// if the configured database is SQLite, turn on foreign key constraints and set a long busy-timeout
if (Capsule::connection() instanceof \Illuminate\Database\SQLiteConnection) {
/*if (Capsule::connection() instanceof \Illuminate\Database\SQLiteConnection) {
try {
Capsule::statement('PRAGMA foreign_keys = on');
Capsule::statement('PRAGMA busy_timeout = ' . (30 * 1000)); // milliseconds
} catch (\Illuminate\Database\QueryException $e) {
// database does not exist yet; do nothing
}
}
}*/
}
private function loadCommonLibraries()

8
src/Movim/Migration.php

@ -27,9 +27,9 @@ class Migration extends AbstractMigration
case 'mysql':
$this->schema->getConnection()->unprepared('SET foreign_key_checks = 1');
break;
case 'sqlite':
/*case 'sqlite':
$this->schema->getConnection()->unprepared('PRAGMA foreign_keys = on');
break;
break;*/
}
}
@ -39,9 +39,9 @@ class Migration extends AbstractMigration
case 'mysql':
$this->schema->getConnection()->unprepared('SET foreign_key_checks = 0');
break;
case 'sqlite':
/*case 'sqlite':
$this->schema->getConnection()->unprepared('PRAGMA foreign_keys = off');
break;
break;*/
}
}
}
Loading…
Cancel
Save