mirror of
https://github.com/danielbrendel/hortusfox-web.git
synced 2026-01-07 05:10:16 -06:00
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class ChatMsgModel_Migration
|
|
*/
|
|
class ChatMsgModel_Migration {
|
|
private $database = null;
|
|
private $connection = null;
|
|
|
|
/**
|
|
* Store the PDO connection handle
|
|
*
|
|
* @param \PDO $pdo The PDO connection handle
|
|
* @return void
|
|
*/
|
|
public function __construct($pdo)
|
|
{
|
|
$this->connection = $pdo;
|
|
}
|
|
|
|
/**
|
|
* Called when the table shall be created or modified
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
$this->database = new Asatru\Database\Migration('ChatMsgModel', $this->connection);
|
|
$this->database->drop();
|
|
$this->database->add('id INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
|
|
$this->database->add('userId INT NOT NULL');
|
|
$this->database->add('message TEXT NOT NULL');
|
|
$this->database->add('sysmsg BOOLEAN NOT NULL DEFAULT 0');
|
|
$this->database->add('created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP');
|
|
$this->database->create();
|
|
}
|
|
|
|
/**
|
|
* Called when the table shall be dropped
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
if ($this->database)
|
|
$this->database->drop();
|
|
}
|
|
} |