Add the migrations to the container.

This commit is contained in:
Dave Smith-Hayes 2024-11-07 22:49:59 -05:00
parent 10e4305e62
commit 7c50e03381
6 changed files with 25 additions and 63 deletions

View File

@ -1,49 +0,0 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
/*
CREATE TABLE images (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
url TEXT NOT NULL,
title TEXT NULL,
width INT(11) UNSIGNED NULL,
height INT(11) UNSIGNED NULL,
PRIMARY KEY(`id`),
UNIQUE KEY(`url`)
);
*/
final class CreateImagesTable 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('images')->addTimestamps();
$table->addColumn('url', 'string')
->addColumn('title', 'string', [ 'null' => false ])
->addColumn('width', 'integer', [
'unsigned' => true,
'null' => true,
])
->addColumn('height', 'integer', [
'unsigned' => true,
'null' => true
])
->addIndex([ 'url' ], [ 'type' => 'unique' ])
->create();
}
}

View File

@ -16,7 +16,7 @@ CREATE TABLE channels (
category VARCHAR(255), category VARCHAR(255),
owner_id INT(11) UNSIGNED NOT NULL, owner_id INT(11) UNSIGNED NOT NULL,
image_id INT(11) UNSIGNED NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@ -55,10 +55,13 @@ final class CreateChannelsTable extends AbstractMigration
]) ])
->addColumn('copyright', 'string') ->addColumn('copyright', 'string')
->addColumn('explicit', 'boolean', [ 'default' => false ]) ->addColumn('explicit', 'boolean', [ 'default' => false ])
->addColumn('owner_id', 'integer') ->addColumn('owner_id', 'integer', [
'null' => false,
'signed' => false,
])
->addColumn('image_id', 'integer', [ ->addColumn('image_id', 'integer', [
'null' => true, 'null' => true,
'unsigned' => true 'signed' => false,
]) ])
->addIndex([ 'name' ], [ 'unique' => true ]) ->addIndex([ 'name' ], [ 'unique' => true ])
->addForeignKey('owner_id', 'users') ->addForeignKey('owner_id', 'users')

View File

@ -47,13 +47,16 @@ final class CreateEpisodesTable extends AbstractMigration
$table->addColumn('title', 'string', [ 'null' => false ]) $table->addColumn('title', 'string', [ 'null' => false ])
->addColumn('link', 'string') ->addColumn('link', 'string')
->addColumn('duration', 'string') ->addColumn('duration', 'string')
->addColumn('length', 'integer', [ 'unsigned' => true ]) ->addColumn('length', 'integer', [ 'signed' => false ])
->addColumn('description', 'text') ->addColumn('description', 'text')
->addColumn('explicit', 'boolean', [ 'default' => false ]) ->addColumn('explicit', 'boolean', [ 'default' => false ])
->addColumn('channel_id', 'integer', [ 'unsigned' => true ]) ->addColumn('channel_id', 'integer', [
'signed' => false,
'null' => false
])
->addColumn('image_id', 'integer', [ ->addColumn('image_id', 'integer', [
'null' => true, 'signed' => false,
'unsigned' => true 'null' => true
]) ])
->addForeignKey('channel_id', 'channels') ->addForeignKey('channel_id', 'channels')
->addForeignKey('image_id', 'images'); ->addForeignKey('image_id', 'images');

View File

@ -38,11 +38,11 @@ final class CreateTransactionsTable extends AbstractMigration
{ {
$table = $this->table('transactions')->addTimestamps(); $table = $this->table('transactions')->addTimestamps();
$table->addColumn('user_id', 'integer', [ 'null' => false ]) $table->addColumn('user_id', 'integer', [ 'signed' => false, 'null' => false ])
->addColumn('code', 'string') ->addColumn('code', 'string')
->addColumn('type', 'string') ->addColumn('type', 'string')
->addColumn('total', 'integer', [ 'null' => false ]) ->addColumn('total', 'integer', [ 'null' => false ])
->addForeignKey('user_id', 'user'); ->addForeignKey('user_id', 'users');
$table->create(); $table->create();
} }

View File

@ -20,10 +20,10 @@ return
], ],
'development' => [ 'development' => [
'adapter' => 'mysql', 'adapter' => 'mysql',
'host' => 'localhost', 'host' => 'mariadb',
'name' => 'development_db', 'name' => 'slovocast',
'user' => 'root', 'user' => 'slovocast',
'pass' => '', 'pass' => 'password',
'port' => '3306', 'port' => '3306',
'charset' => 'utf8', 'charset' => 'utf8',
], ],

View File

@ -1,5 +1,7 @@
FROM php:8.3-fpm FROM php:8.3-fpm
WORKDIR /var/www/slovocast
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y libonig-dev \ apt-get install -y libonig-dev \
zip \ zip \
@ -7,3 +9,6 @@ RUN apt-get update && \
libpng-dev libpng-dev
RUN docker-php-ext-install pdo pdo_mysql mbstring gd zip RUN docker-php-ext-install pdo pdo_mysql mbstring gd zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer