2024-06-27 23:24:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
|
|
|
|
/**
|
|
|
|
CREATE TABLE `transactions` (
|
|
|
|
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
channel_id INT(11) UNSIGNED NOT NULL,
|
|
|
|
code VARCHAR(255) NOT NULL,
|
|
|
|
type VARCHAR(255) NOT NULL,
|
|
|
|
|
|
|
|
total INT(11) NOT NULL,
|
|
|
|
|
|
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2024-06-28 02:29:12 +00:00
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
2024-06-27 23:24:56 +00:00
|
|
|
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
FOREIGN KEY (`channel_id`) REFERENCES channels(`id`)
|
|
|
|
);
|
|
|
|
*/
|
|
|
|
|
|
|
|
final class CreateTransactionsTable extends AbstractMigration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Change Method.
|
|
|
|
*
|
|
|
|
* Write your reversible migrations using this method.
|
|
|
|
*
|
|
|
|
* More information on writing migrations is available here:
|
|
|
|
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
|
|
|
*
|
|
|
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
|
|
|
* with the Table class.
|
|
|
|
*/
|
|
|
|
public function change(): void
|
|
|
|
{
|
|
|
|
$table = $this->table('transactions')->addTimestamps();
|
|
|
|
|
|
|
|
$table->addColumn('user_id', 'integer', [ 'null' => false ])
|
|
|
|
->addColumn('code', 'string')
|
|
|
|
->addColumn('type', 'string')
|
2024-06-28 02:29:12 +00:00
|
|
|
->addColumn('total', 'integer', [ 'null' => false ])
|
2024-06-27 23:24:56 +00:00
|
|
|
->addForeignKey('user_id', 'user');
|
|
|
|
|
|
|
|
$table->create();
|
|
|
|
}
|
|
|
|
}
|