public function safeUp()
 {
     $this->createTable('user', ['id' => Schema::TYPE_PK, 'username' => Schema::TYPE_STRING . '(40) NOT NULL', 'email' => Schema::TYPE_STRING . '(255) NOT NULL', 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', 'password_hash' => Schema::TYPE_STRING . '(255) NOT NULL', 'dynamic_key' => Schema::TYPE_STRING . '(10) DEFAULT NULL', 'dynamic_key_expired_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL', 'is_blocked' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'is_activated' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP', 'updated_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL'], Common::getTableOptions($this->db));
     $this->createIndex('user_username_unique', 'user', 'username', true);
     $this->createIndex('user_email_unique', 'user', 'email', true);
     $this->createIndex('user_auth_key_unique', 'user', 'auth_key', true);
 }
 public function safeUp()
 {
     $this->createTable('message_record', ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'number' => Schema::TYPE_STRING . ' NOT NULL', 'event_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP'], Common::getTableOptions($this->db));
     $this->createIndex('message_record_number_event_id_unique', 'message_record', ['number', 'event_id'], true);
     $this->addForeignKey('message_record_user_id', 'message_record', 'user_id', 'user', 'id');
     $this->addForeignKey('message_record_event_id', 'message_record', 'event_id', 'event', 'id');
 }
 public function safeUp()
 {
     $this->createTable('location_new', ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'event_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'provider_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'city' => Schema::TYPE_STRING . '(255) NOT NULL', 'title_from_provider' => Schema::TYPE_STRING . '(255) NOT NULL', 'title_from_API' => Schema::TYPE_STRING . '(255) NOT NULL', 'latitude' => Schema::TYPE_DECIMAL . '(13,10) NOT NULL', 'longitude' => Schema::TYPE_DECIMAL . '(13,10) NOT NULL', 'is_reliable' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'occur_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP'], Common::getTableOptions($this->db));
     $this->createIndex('location_new_event_provider_latitude_longitude', 'location_new', ['event_id', 'provider_id', 'latitude', 'longitude'], true);
     $this->addForeignKey('location_new_user_id', 'location_new', 'user_id', 'user', 'id');
     $this->addForeignKey('location_new_event_id', 'location_new', 'event_id', 'event', 'id', 'CASCADE');
     $this->addForeignKey('location_new_provider_id', 'location_new', 'provider_id', 'location_provider', 'id');
 }
 public function safeUp()
 {
     $this->createTable('profile', ['id' => Schema::TYPE_PK, 'event_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'name' => Schema::TYPE_STRING . '(40) NOT NULL', 'age' => Schema::TYPE_INTEGER . ' NOT NULL', 'gender' => 'enum("male","female") NOT NULL DEFAULT "male"', 'height' => Schema::TYPE_INTEGER . ' NOT NULL', 'dress' => Schema::TYPE_STRING . '(255) NOT NULL', 'appearance' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP', 'updated_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL'], Common::getTableOptions($this->db));
     $this->addForeignKey('profile_event_id', 'profile', 'event_id', 'event', 'id', 'CASCADE');
 }
 public function safeUp()
 {
     $this->createTable('location_current', ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'event_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'is_origin' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'title' => Schema::TYPE_STRING . '(255) NOT NULL', 'latitude' => Schema::TYPE_DECIMAL . '(13,10) NOT NULL', 'longitude' => Schema::TYPE_DECIMAL . '(13,10) NOT NULL', 'occur_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP'], Common::getTableOptions($this->db));
     $this->addForeignKey('location_current_user_id', 'location_current', 'user_id', 'user', 'id');
     $this->addForeignKey('location_current_event_id', 'location_current', 'event_id', 'event', 'id', 'CASCADE');
 }
 public function safeUp()
 {
     $this->createTable('event', ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'city' => Schema::TYPE_STRING . '(255) NOT NULL', 'theme' => Schema::TYPE_STRING . '(255) NOT NULL', 'description' => Schema::TYPE_TEXT, 'is_finished' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'urgent' => 'enum("mild","urgent","emergency") NOT NULL DEFAULT "mild"', 'occur_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP', 'updated_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL'], Common::getTableOptions($this->db));
     $this->addForeignKey('event_user_id', 'event', 'user_id', 'user', 'id');
 }
 public function safeUp()
 {
     $this->createTable('admin', ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'is_blocked' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP', 'updated_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL'], Common::getTableOptions($this->db));
     $this->createIndex('admin_user_id_unique', 'admin', 'user_id', true);
     $this->addForeignKey('admin_user_id', 'admin', 'user_id', 'user', 'id');
 }
 public function safeUp()
 {
     $this->createTable('location_provider', ['id' => Schema::TYPE_PK, 'identity_kind' => 'enum("police","monitor_system","people") NOT NULL DEFAULT "police"', 'identity_info' => Schema::TYPE_STRING . '(255) NOT NULL', 'latitude' => Schema::TYPE_DECIMAL . '(13,10) DEFAULT NULL', 'longitude' => Schema::TYPE_DECIMAL . '(13,10) DEFAULT NULL', 'provided_at' => Schema::TYPE_TIMESTAMP . ' NULL DEFAULT NULL', 'created_at' => Schema::TYPE_TIMESTAMP . ' NOT NULL DEFAULT CURRENT_TIMESTAMP'], Common::getTableOptions($this->db));
     $this->createIndex('provider_identity_info', 'location_provider', 'identity_info', true);
 }