Start the channels table migration.
This commit is contained in:
parent
18d995e38d
commit
2d6dee2f0c
61
app/db/migrations/20240624023258_create_channels_table.php
Normal file
61
app/db/migrations/20240624023258_create_channels_table.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE TABLE channels (
|
||||||
|
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
description TEXT NOT NULL,
|
||||||
|
link VARCHAR(255) NULL,
|
||||||
|
language VARCHAR(2) NOT NULL,
|
||||||
|
copyright VARCHAR(255) NULL,
|
||||||
|
explicit BOOLEAN DEFAULT false,
|
||||||
|
category VARCHAR(255),
|
||||||
|
|
||||||
|
owner_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(`owner_id`) REFERENCES users(`id`),
|
||||||
|
FOREIGN KEY(`image_id`) REFERENCES images(`id`),
|
||||||
|
UNIQUE KEY(`name`)
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class CreateChannelsTable 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('channels')->addTimestamps();
|
||||||
|
|
||||||
|
$table->addColumn('name', 'string')
|
||||||
|
->addColumn('description', 'string', [ 'null' => false ])
|
||||||
|
->addColumn('links', 'string')
|
||||||
|
->addColumn('language', 'string')
|
||||||
|
->addColumn('copyright', 'string')
|
||||||
|
->addColumn('explicit', 'boolean', [ 'default' => false ])
|
||||||
|
->addColumn('category', 'string')
|
||||||
|
->addColumn('owner_id', 'integer')
|
||||||
|
->addColumn('image_id', 'integer')
|
||||||
|
->addIndex([ 'name' ], [ 'unique' => true ])
|
||||||
|
->addForeignKey('owner_id', 'users')
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user