Merge pull request #1964 from dshoreman/date-fixes

Date fixes
This commit is contained in:
Samuel Georges 2016-04-30 05:21:32 +10:00
commit 1c8de67610
34 changed files with 157 additions and 45 deletions

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendUsers extends Migration
{
public function up()
{
Schema::create('backend_users', function ($table) {
Schema::create('backend_users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('first_name')->nullable();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendUserGroups extends Migration
{
public function up()
{
Schema::create('backend_user_groups', function ($table) {
Schema::create('backend_user_groups', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->unique('name_unique');

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendUsersGroups extends Migration
{
public function up()
{
Schema::create('backend_users_groups', function ($table) {
Schema::create('backend_users_groups', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->integer('user_id')->unsigned();
$table->integer('user_group_id')->unsigned();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendUserThrottle extends Migration
{
public function up()
{
Schema::create('backend_user_throttle', function ($table) {
Schema::create('backend_user_throttle', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable()->index();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendUserPreferences extends Migration
{
public function up()
{
Schema::create('backend_user_preferences', function ($table) {
Schema::create('backend_user_preferences', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('user_id')->unsigned();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendAccessLog extends Migration
{
public function up()
{
Schema::create('backend_access_log', function ($table) {
Schema::create('backend_access_log', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('user_id')->unsigned();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbBackendAddDescriptionField extends Migration
{
public function up()
{
Schema::table('backend_user_groups', function ($table) {
Schema::table('backend_user_groups', function (Blueprint $table) {
$table->string('code')->nullable()->index('code_index');
$table->text('description')->nullable();
$table->boolean('is_new_user_default')->default(false);
@ -15,7 +16,7 @@ class DbBackendAddDescriptionField extends Migration
public function down()
{
// Schema::table('backend_user_groups', function ($table) {
// Schema::table('backend_user_groups', function (Blueprint $table) {
// $table->dropColumn('code');
// $table->dropColumn('description');
// $table->dropColumn('is_new_user_default');

View File

@ -1,5 +1,6 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
use Backend\Models\User as AdminModel;
@ -7,7 +8,7 @@ class DbBackendAddSuperuserFlag extends Migration
{
public function up()
{
Schema::table('backend_users', function ($table) {
Schema::table('backend_users', function (Blueprint $table) {
$table->boolean('is_superuser')->default(false);
});
@ -21,7 +22,7 @@ class DbBackendAddSuperuserFlag extends Migration
public function down()
{
// Schema::table('backend_users', function ($table) {
// Schema::table('backend_users', function (Blueprint $table) {
// $table->dropColumn('is_superuser');
// });
}

View File

@ -0,0 +1,28 @@
<?php
use October\Rain\Database\Updates\Migration;
class DbBackendTimestampFix extends Migration
{
protected $backendTables = [
'users',
'user_groups',
'access_log',
];
public function up()
{
// Disable all special modes such as NO_ZERO_DATE to prevent any
// errors from MySQL before we can update the timestamp columns.
Db::statement("SET @@SQL_MODE=''");
foreach ($this->backendTables as $table) {
DbDongle::convertTimestamps($table);
}
}
public function down()
{
// ...
}
}

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbCmsThemeData extends Migration
{
public function up()
{
Schema::create('cms_theme_data', function ($table) {
Schema::create('cms_theme_data', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('theme')->nullable()->index();

View File

@ -0,0 +1,19 @@
<?php
use October\Rain\Database\Updates\Migration;
class DbCmsTimestampFix extends Migration
{
public function up()
{
// Disable all special modes such as NO_ZERO_DATE to prevent any
// errors from MySQL before we can update the timestamp columns.
Db::statement("SET @@SQL_MODE=''");
DbDongle::convertTimestamps('cms_theme_data');
}
public function down()
{
// ...
}
}

View File

@ -26,7 +26,6 @@ return [
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Url' => Illuminate\Support\Facades\URL::class, // Preferred
@ -52,6 +51,7 @@ return [
'Ini' => October\Rain\Support\Facades\Ini::class,
'Twig' => October\Rain\Support\Facades\Twig::class,
'DbDongle' => October\Rain\Support\Facades\DbDongle::class,
'Schema' => October\Rain\Support\Facades\Schema::class,
'Backend' => Backend\Facades\Backend::class,
'BackendMenu' => Backend\Facades\BackendMenu::class,
'BackendAuth' => Backend\Facades\BackendAuth::class,

View File

@ -366,6 +366,8 @@ class UpdateManager
*/
public function migrateModule($module)
{
DbDongle::disableStrictMode();
$this->migrator->run(base_path() . '/modules/'.strtolower($module).'/database/migrations');
$this->note($module);

View File

@ -385,6 +385,8 @@ class VersionManager
*/
protected function applyDatabaseScript($code, $version, $script)
{
DbDongle::disableStrictMode();
/*
* Execute the database PHP script
*/
@ -405,6 +407,8 @@ class VersionManager
*/
protected function removeDatabaseScript($code, $version, $script)
{
DbDongle::disableStrictMode();
/*
* Execute the database PHP script
*/

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbDeferredBindings extends Migration
{
public function up()
{
Schema::create('deferred_bindings', function ($table) {
Schema::create('deferred_bindings', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('master_type')->index();

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemFiles extends Migration
{
public function up()
{
Schema::create('system_files', function ($table) {
Schema::create('system_files', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('disk_name');

View File

@ -1,18 +1,18 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemPluginVersions extends Migration
{
public function up()
{
Schema::create('system_plugin_versions', function ($table) {
Schema::create('system_plugin_versions', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('code')->index();
$table->string('version', 50);
$table->timestamp('created_at');
$table->timestamp('created_at')->nullable();
});
}

View File

@ -1,19 +1,20 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemPluginHistory extends Migration
{
public function up()
{
Schema::create('system_plugin_history', function ($table) {
Schema::create('system_plugin_history', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('code')->index();
$table->string('type', 20)->index();
$table->string('version', 50);
$table->string('detail')->nullable();
$table->timestamp('created_at');
$table->timestamp('created_at')->nullable();
});
}

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemSettings extends Migration
{
public function up()
{
Schema::create('system_settings', function ($table) {
Schema::create('system_settings', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('item')->nullable()->index();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemParameters extends Migration
{
public function up()
{
Schema::create('system_parameters', function ($table) {
Schema::create('system_parameters', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('namespace', 100);

View File

@ -1,19 +1,20 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemAddDisabledFlag extends Migration
{
public function up()
{
Schema::table('system_plugin_versions', function ($table) {
Schema::table('system_plugin_versions', function (Blueprint $table) {
$table->boolean('is_disabled')->default(0);
});
}
public function down()
{
Schema::table('system_plugin_versions', function ($table) {
Schema::table('system_plugin_versions', function (Blueprint $table) {
$table->dropColumn('is_disabled');
});
}

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemMailTemplates extends Migration
{
public function up()
{
Schema::create('system_mail_templates', function ($table) {
Schema::create('system_mail_templates', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('code')->nullable();

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemMailLayouts extends Migration
{
public function up()
{
Schema::create('system_mail_layouts', function ($table) {
Schema::create('system_mail_layouts', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->nullable();

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbJobs extends Migration
{
public function up()
{
Schema::create('jobs', function ($table) {
Schema::create('jobs', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id');
$table->string('queue');

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemEventLogs extends Migration
{
public function up()
{
Schema::create('system_event_logs', function ($table) {
Schema::create('system_event_logs', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('level')->nullable()->index();

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemRequestLogs extends Migration
{
public function up()
{
Schema::create('system_request_logs', function ($table) {
Schema::create('system_request_logs', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('status_code')->nullable();

View File

@ -1,10 +1,10 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemSessions extends Migration
{
/**
* Run the migrations.
*
@ -12,7 +12,7 @@ class DbSystemSessions extends Migration
*/
public function up()
{
Schema::create('sessions', function ($table) {
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
$table->text('payload')->nullable();
$table->integer('last_activity')->nullable();

View File

@ -1,6 +1,7 @@
<?php
use System\Models\MailLayout;
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemMailLayoutRename extends Migration

View File

@ -1,19 +1,20 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemAddFrozenFlag extends Migration
{
public function up()
{
Schema::table('system_plugin_versions', function ($table) {
Schema::table('system_plugin_versions', function (Blueprint $table) {
$table->boolean('is_frozen')->default(0);
});
}
public function down()
{
Schema::table('system_plugin_versions', function ($table) {
Schema::table('system_plugin_versions', function (Blueprint $table) {
$table->dropColumn('is_frozen');
});
}

View File

@ -1,12 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbCache extends Migration
{
public function up()
{
Schema::create('cache', function ($table) {
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->unique();
$table->text('value');
$table->integer('expiration');

View File

@ -1,13 +1,13 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemRevisions extends Migration
{
public function up()
{
Schema::create('system_revisions', function ($table) {
Schema::create('system_revisions', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable()->index();

View File

@ -1,18 +1,19 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbFailedJobs extends Migration
{
public function up()
{
Schema::create('failed_jobs', function ($table) {
Schema::create('failed_jobs', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->text('connection');
$table->text('queue');
$table->text('payload');
$table->timestamp('failed_at');
$table->timestamp('failed_at')->nullable();
});
}

View File

@ -1,19 +1,20 @@
<?php
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;
class DbSystemPluginHistoryDetailText extends Migration
{
public function up()
{
Schema::table('system_plugin_history', function ($table) {
Schema::table('system_plugin_history', function (Blueprint $table) {
$table->text('detail')->nullable()->change();
});
}
public function down()
{
Schema::table('system_plugin_history', function ($table) {
Schema::table('system_plugin_history', function (Blueprint $table) {
$table->string('detail')->nullable()->change();
});
}

View File

@ -0,0 +1,40 @@
<?php
use October\Rain\Database\Updates\Migration;
class DbSystemTimestampFix extends Migration
{
protected $coreTables = [
'deferred_bindings',
'failed_jobs' => 'failed_at',
'system_files',
'system_event_logs',
'system_mail_layouts',
'system_mail_templates',
'system_plugin_history' => 'created_at',
'system_plugin_versions' => 'created_at',
'system_request_logs',
'system_revisions',
];
public function up()
{
// Disable all special modes such as NO_ZERO_DATE to prevent any
// errors from MySQL before we can update the timestamp columns.
Db::statement("SET @@SQL_MODE=''");
foreach ($this->coreTables as $table => $columns) {
if (is_int($table)) {
$table = $columns;
$columns = ['created_at', 'updated_at'];
}
DbDongle::convertTimestamps($table, $columns);
}
}
public function down()
{
// ...
}
}