Permalink
Browse files

Consolidate date formats and column names

We had some unix timestamps and some datetime fields, some called created_at and some called created_on. Now its all datetime, created_at (non-null) and updated_at (nullable).
  • Loading branch information...
1 parent f297dda commit cf29cbb7a10f5999d9d5a9cc5c03760dbbdb6715 Phil Sturgeon committed Feb 24, 2014
Showing with 1,229 additions and 357 deletions.
  1. +1 −1 addons/shared_addons/themes/base/views/modules/blog/archive.php
  2. +1 −1 addons/shared_addons/themes/base/views/modules/blog/posts.php
  3. +1 −1 addons/shared_addons/themes/base/views/modules/blog/tagged.php
  4. +1 −1 addons/shared_addons/themes/base/views/modules/blog/view.php
  5. +1 −1 installer/controllers/installer.php
  6. +13 −1 installer/libraries/Installer_lib.php
  7. +3 −1 installer/libraries/Module_import.php
  8. +13 −10 installer/models/install_m.php
  9. +18 −0 system/cms/migrations/137_Make_field_name_nullable.php
  10. +3 −3 system/cms/modules/addons/src/Pyro/Module/Addons/ModuleManager.php
  11. +1 −1 system/cms/modules/addons/src/Pyro/Module/Addons/ModuleModel.php
  12. +154 −153 system/cms/modules/addons/src/Pyro/Module/Addons/ThemeManager.php
  13. +14 −14 system/cms/modules/addons/src/Pyro/Module/Addons/WidgetInstanceModel.php
  14. +1 −1 system/cms/modules/addons/src/Pyro/Module/Addons/WidgetModel.php
  15. +3 −3 system/cms/modules/blog/controllers/admin.php
  16. +12 −12 system/cms/modules/blog/models/blog_m.php
  17. +5 −5 system/cms/modules/blog/plugin.php
  18. +3 −3 system/cms/modules/blog/views/admin/form.php
  19. +3 −3 system/cms/modules/blog/views/admin/form/tabs/options.php
  20. +1 −1 system/cms/modules/blog/views/archive.php
  21. +1 −1 system/cms/modules/blog/views/posts.php
  22. +1 −1 system/cms/modules/blog/views/view.php
  23. +1 −1 system/cms/modules/comments/controllers/admin.php
  24. +0 −1 system/cms/modules/comments/controllers/comments.php
  25. +1 −1 system/cms/modules/comments/details.php
  26. +3 −3 system/cms/modules/comments/src/Pyro/Module/Comments/Model/Comment.php
  27. +1 −1 system/cms/modules/comments/views/admin/preview.php
  28. +1 −1 system/cms/modules/comments/views/admin/tables/comments.php
  29. +1 −1 system/cms/modules/comments/views/display.php
  30. +16 −20 system/cms/modules/pages/controllers/admin.php
  31. +2 −2 system/cms/modules/pages/controllers/pages.php
  32. +35 −33 system/cms/modules/pages/controllers/sitemap.php
  33. +10 −9 system/cms/modules/pages/details.php
  34. +4 −4 system/cms/modules/pages/plugin.php
  35. +3 −3 system/cms/modules/search/details.php
  36. +1 −1 system/cms/modules/search/src/Pyro/Module/Search/Model/Search.php
  37. +303 −0 system/cms/modules/streams_core/models/DefaultSite/Pyro/Module/Streams/Model/BlogsBlogEntryModel.php
  38. +65 −0 ...odules/streams_core/models/DefaultSite/Pyro/Module/Streams/Model/PagesDefPageFieldsEntryModel.php
  39. +395 −0 ...cms/modules/streams_core/models/DefaultSite/Pyro/Module/Streams/Model/UsersProfilesEntryModel.php
  40. +90 −0 ...odules/streams_core/models/DefaultSite/Pyro/Module/Streams/Model/VariablesVariablesEntryModel.php
  41. +2 −18 system/cms/modules/streams_core/models/fields_m.php
  42. +2 −6 system/cms/modules/streams_core/models/streams_m.php
  43. +11 −2 system/cms/modules/streams_core/src/Pyro/Module/Streams/Entry/EntryModel.php
  44. +4 −4 system/cms/modules/streams_core/src/Pyro/Module/Streams/Field/FieldAssignmentModel.php
  45. +4 −1 system/cms/modules/streams_core/src/Pyro/Module/Streams/Field/FieldModel.php
  46. +2 −6 system/cms/modules/users/controllers/admin.php
  47. +8 −5 system/cms/modules/users/details.php
  48. +3 −8 system/cms/modules/users/src/Pyro/Module/Users/Model/User.php
  49. +1 −1 system/cms/modules/users/views/admin/users/tables/users.php
  50. +0 −1 system/cms/modules/widgets/controllers/admin.php
  51. +4 −4 system/cms/modules/widgets/details.php
  52. +1 −1 system/cms/plugins/user.php
  53. +1 −1 system/cms/themes/pyrocms/views/admin/dashboard.php
@@ -9,7 +9,7 @@
<div class="post_date">
<span class="date">
{{ theme:image file="date.png" }}
- About {{ helper:timespan timestamp=created_on }} ago.
+ About {{ helper:timespan timestamp=created_at }} ago.
</span>
</div>
@@ -9,7 +9,7 @@
<div class="post_date">
<span class="date">
{{ theme:image file="date.png" }}
- About {{ helper:timespan timestamp=created_on }} ago.
+ About {{ helper:timespan timestamp=created_at }} ago.
</span>
</div>
@@ -9,7 +9,7 @@
<div class="post_date">
<span class="date">
{{ theme:image file="date.png" }}
- About {{ helper:timespan timestamp=created_on }} ago.
+ About {{ helper:timespan timestamp=created_at }} ago.
</span>
</div>
@@ -8,7 +8,7 @@
<div class="post_date">
<span class="date">
{{ theme:image file="date.png" }}
- About {{ helper:timespan timestamp=created_on }} ago.
+ About {{ helper:timespan timestamp=created_at }} ago.
</span>
</div>
@@ -428,7 +428,7 @@ public function step_4()
// Let's try to install the system with this new PDO instance
try {
$pdb = $this->installer_lib->install($user, $db_config);
- } catch (Exception $e) {
+ } catch (InstallerException $e) {
$this->_render_view('step_4', array(
'messages' => array(
@@ -169,7 +169,19 @@ public function create_connection($config)
*/
public function create_db(PDO $conn, $database)
{
- return $conn->query("CREATE DATABASE {$database}");
+ try {
+ return $conn->query("CREATE DATABASE {$database}");
+ } catch (PDOException $e) {
+
+ // PostgreSQL says this is a duplicate database
+ if ($e->getCode() === '42P04') {
+ // If this table already exists then great, our work here is done
+ return true;
+ } else {
+ // Unkown issue creating the table
+ throw new InstallerException("Unkown issue creating the database: ".$e->getMessage());
+ }
+ }
}
/**
@@ -153,7 +153,8 @@ public function add($module)
'menu' => ! empty($module['menu']) ? $module['menu'] : false,
'enabled' => (bool) $module['enabled'],
'installed' => (bool) $module['installed'],
- 'is_core' => (bool) $module['is_core']
+ 'is_core' => (bool) $module['is_core'],
+ 'created_at' => date('Y-m-d H:i:s'),
)
);
}
@@ -204,6 +205,7 @@ public function import_all()
'last_name' => $user['lastname'],
'display_name' => $user['firstname'].' '.$user['lastname'],
'lang' => 'en',
+ 'created_at' => date('Y-m-d H:i:s'),
));
// After modules are imported we need to modify the settings table
@@ -64,8 +64,8 @@ public function set_default_structure(Connection $conn, array $user, array $db)
$table->string('ref', 20);
$table->string('domain', 100);
$table->boolean('is_activated')->default(true);
- $table->integer('created_on');
- $table->integer('updated_on')->nullable();
+ $table->dateTime('created_at');
+ $table->dateTime('updated_at')->nullable();
$table->unique('ref');
$table->unique('domain');
@@ -85,9 +85,9 @@ public function set_default_structure(Connection $conn, array $user, array $db)
$table->string('activation_code')->nullable();
$table->string('persist_code')->nullable();
$table->string('reset_password_code')->nullable();
- $table->integer('created_on');
- $table->integer('updated_on')->nullable();
- $table->integer('last_login')->nullable();
+ $table->dateTime('created_at');
+ $table->dateTime('updated_at')->nullable();
+ $table->dateTime('last_login')->nullable();
$table->unique('email');
$table->unique('username');
@@ -105,7 +105,7 @@ public function set_default_structure(Connection $conn, array $user, array $db)
'password' => $password,
'ip_address' => $this->input->ip_address(),
'is_activated'=> true,
- 'created_on' => time(),
+ 'created_at' => date('Y-m-d H:i:s'),
);
// Create User tables
@@ -177,7 +177,8 @@ public function set_default_structure(Connection $conn, array $user, array $db)
$table->boolean('enabled');
$table->boolean('installed');
$table->boolean('is_core');
- $table->integer('updated_on')->nullable();
+ $table->dateTime('created_at');
+ $table->dateTime('updated_at')->nullable();
$table->unique('slug');
$table->index('enabled');
@@ -200,8 +201,8 @@ public function set_default_structure(Connection $conn, array $user, array $db)
$table->string('type')->nullable();
$table->boolean('enabled')->default(true);
$table->integer('order')->default(0);
- $table->integer('created_on');
- $table->integer('updated_on')->nullable();
+ $table->dateTime('created_at');
+ $table->dateTime('updated_at')->nullable();
});
$schema->dropIfExists('theme_options');
@@ -266,6 +267,8 @@ public function set_default_structure(Connection $conn, array $user, array $db)
$table->text('field_data')->nullable();
$table->text('view_options')->nullable();
$table->enum('locked', array('yes', 'no'))->default('no');
+ $table->dateTime('created_at');
+ $table->dateTime('updated_at')->nullable();
});
// Assignments Table
@@ -279,7 +282,7 @@ public function set_default_structure(Connection $conn, array $user, array $db)
$table->enum('required', array('yes', 'no'))->default('no');
$table->enum('unique', array('yes', 'no'))->default('no');
$table->text('instructions')->nullable();
- $table->string('field_name', 60);
+ $table->string('field_name', 60)->nullable();
// $table->foreign('stream_id'); //TODO Set up foreign keys
// $table->foreign('field_id'); //TODO Set up foreign keys
@@ -0,0 +1,18 @@
+<?php defined('BASEPATH') or exit('No direct script access allowed');
+
+class Migration_Make_field_name_nullable extends CI_Migration
+{
+ public function up()
+ {
+ $prefix = ci()->pdb->getQueryGrammar()->getTablePrefix();
+
+ ci()->pdb->statement("ALTER TABLE `" . $prefix . "_data_field_assignments` MODIFY `field_name` VARCHAR(60);");
+
+ return true;
+ }
+
+ public function down()
+ {
+ return true;
+ }
+}
@@ -156,7 +156,7 @@ public function get($slug)
'current_version' => $this->version($record->slug),
'path' => $location,
'field_types' => ! empty($info['field_types']) ? $info['field_types'] : false,
- 'updated_on' => $record->updated_on
+ 'updated_at' => $record->updated_at
);
}
@@ -227,7 +227,7 @@ public function getAll($params = null, $return_disabled = true, $fresh = true)
'current_version' => $this->version($record->slug),
'path' => $location,
'field_types' => ! empty($info['field_types']) ? $info['field_types'] : false,
- 'updated_on' => $record->updated_on
+ 'updated_at' => $record->updated_at
);
// store these
@@ -473,7 +473,7 @@ public function registerUnavailableModules()
'is_backend' => ! empty($input['backend']),
'skip_xss' => ! empty($input['skip_xss']),
'menu' => ! empty($input['menu']) ? $input['menu'] : false,
- 'updated_on' => time()
+ 'updated_at' => date('Y-m-d H:i:s')
));
log_message('debug', sprintf('The information of the module "%s" has been updated', $slug));
@@ -37,7 +37,7 @@ class ModuleModel extends Eloquent
*
* @var boolean
*/
- public $timestamps = false;
+ public $timestamps = true;
/**
* Find All
Oops, something went wrong.

0 comments on commit cf29cbb

Please sign in to comment.