Permalink
Browse files

Add migrations and schema snapshot with a new triggered_by column

  • Loading branch information...
1 parent f0044c6 commit f734cff3e7c22cebd7209f022df2fb87573e3312 @simkimsia simkimsia committed Dec 15, 2011
@@ -0,0 +1,88 @@
+<?php
+class M4ee9c5c96ee4475092c352c71507707a extends CakeMigration {
+
+/**
+ * Migration description
+ *
+ * @var string
+ * @access public
+ */
+ public $description = '';
+
+/**
+ * Actions to be performed
+ *
+ * @var array $migration
+ * @access public
+ */
+ public $migration = array(
+ 'up' => array(
+ 'create_field' => array(
+ 'logs' => array(
+ 'triggered_by' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8', 'after' => 'ip'),
+ ),
+ ),
+ 'alter_field' => array(
+ 'logs' => array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary', 'collate' => NULL, 'comment' => ''),
+ 'user_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'collate' => NULL, 'comment' => ''),
+ 'model_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'key' => 'index', 'collate' => NULL, 'comment' => ''),
+ 'version_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'key' => 'unique', 'collate' => NULL, 'comment' => ''),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL, 'collate' => NULL, 'comment' => ''),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'description' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'model' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'action' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'change' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'browser' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'request' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ 'ip' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'comment' => ''),
+ ),
+ ),
+ ),
+ 'down' => array(
+ 'drop_field' => array(
+ 'logs' => array('triggered_by',),
+ ),
+ 'alter_field' => array(
+ 'logs' => array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
+ 'user_id' => array('type' => 'integer', 'null' => true, 'default' => NULL),
+ 'model_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'key' => 'index'),
+ 'version_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'key' => 'unique'),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'description' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'model' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'action' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'change' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'browser' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'request' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'ip' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ ),
+ ),
+ ),
+ );
+
+/**
+ * Before migration callback
+ *
+ * @param string $direction, up or down direction of migration process
+ * @return boolean Should process continue
+ * @access public
+ */
+ public function before($direction) {
+ return true;
+ }
+
+/**
+ * After migration callback
+ *
+ * @param string $direction, up or down direction of migration process
+ * @return boolean Should process continue
+ * @access public
+ */
+ public function after($direction) {
+ return true;
+ }
+}
View
@@ -2,5 +2,7 @@
$map = array(
1 => array(
'001_initial_migration' => 'M4dc77a8a57484f4fab0e49b3cbdd56cb'),
+ 2 => array(
+ '002_add_triggered_by_column_to_logs_table' => 'M4ee9c5c96ee4475092c352c71507707a'),
);
?>
View
@@ -0,0 +1,32 @@
+<?php
+/* generated on: 2011-12-15 10:33:03 : 1323945183 */
+class LogSchema extends CakeSchema {
+
+ public $file = 'schema_1.php';
+
+ public function before($event = array()) {
+ return true;
+ }
+
+ public function after($event = array()) {
+ }
+
+ public $logs = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary', 'collate' => NULL, 'comment' => ''),
+ 'user_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'collate' => NULL, 'comment' => ''),
+ 'model_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'key' => 'index', 'collate' => NULL, 'comment' => ''),
+ 'version_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'key' => 'unique', 'collate' => NULL, 'comment' => ''),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL, 'collate' => NULL, 'comment' => ''),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'description' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'model' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'action' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'change' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'browser' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'request' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'ip' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'triggered_by' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'comment' => '', 'charset' => 'utf8'),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'version_id' => array('column' => 'version_id', 'unique' => 1), 'model_id' => array('column' => 'model_id', 'unique' => 0)),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+}

0 comments on commit f734cff

Please sign in to comment.