Add the rest of the tables.
This commit is contained in:
parent
39dc0687eb
commit
16b0198c88
60
app/db/migrations/20240627230956_create_episodes_table.php
Normal file
60
app/db/migrations/20240627230956_create_episodes_table.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
/*
|
||||
CREATE TABLE episodes (
|
||||
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
link VARCHAR(255) NOT NULL,
|
||||
duration VARCHAR(127) NOT NULL COMMENT "HH:MM:SS representation",
|
||||
length INT(11) UNSIGNED NOT NULL COMMENT "Length in seconds",
|
||||
description TEXT NOT NULL,
|
||||
|
||||
explicit BOOLEAN NOT NULL DEFAULT true,
|
||||
|
||||
channel_id INT(11) UNSIGNED NOT NULL,
|
||||
image_id INT(11) UNSIGNED NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY(`channel_id`) REFERENCES channels(`id`),
|
||||
FOREIGN KEY(`image_id`) REFERENCES images(`id`)
|
||||
);
|
||||
*/
|
||||
|
||||
final class CreateEpisodesTable 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('episodes')->addTimestamps();
|
||||
|
||||
$table->addColumn('title', 'string', [ 'null' => false ])
|
||||
->addColumn('link', 'string')
|
||||
->addColumn('duration', 'string')
|
||||
->addColumn('length', 'integer')
|
||||
->addColumn('description', 'text')
|
||||
->addColumn('explicit', 'boolean', [ 'default' => false ])
|
||||
->addColumn('channel_id', 'integer')
|
||||
->addColumn('image_id', 'integer', [ 'null' => true ])
|
||||
->addForeignKey('channel_id', 'channels')
|
||||
->addForeignKey('image_id', 'images');
|
||||
|
||||
$table->create();
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?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,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
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')
|
||||
->addColumn('total', 'int', [ 'null' => false ])
|
||||
->addForeignKey('user_id', 'user');
|
||||
|
||||
$table->create();
|
||||
}
|
||||
}
|
42
app/db/migrations/20240627231953_create_categories_table.php
Normal file
42
app/db/migrations/20240627231953_create_categories_table.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
/**
|
||||
CREATE TABLE `categories` (
|
||||
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY(`name`)
|
||||
);
|
||||
*/
|
||||
|
||||
final class CreateCategoriesTable 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('categories')->addTimestamps();
|
||||
|
||||
$table->addColumn('name', 'string', [ 'null' => false ])
|
||||
->addIndex('name', [ 'unique' => true ]);
|
||||
|
||||
$table->create();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user