Add some migrations for the CodeIgniter application.
This commit is contained in:
parent
0152db25e9
commit
06c1d292bb
39
app/app/Database/Migrations/2024-05-13-011205_AddUsers.php
Normal file
39
app/app/Database/Migrations/2024-05-13-011205_AddUsers.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddUsers extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'email' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 255
|
||||
],
|
||||
'password' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 255,
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'VARCHARD',
|
||||
'constraint' => 255,
|
||||
]
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->createTable('users');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('users');
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
/**
|
||||
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`)
|
||||
*/
|
||||
|
||||
class CreateChannels extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 255,
|
||||
],
|
||||
'description' => [
|
||||
'type' => 'TEXT',
|
||||
],
|
||||
'link' => [
|
||||
'type' => 'TEXT'
|
||||
],
|
||||
'language' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 2,
|
||||
],
|
||||
'copyright' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint', 255,
|
||||
],
|
||||
|
||||
]
|
||||
]);
|
||||
|
||||
$this->forge->createTable('channels');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('channels');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateEpisodes extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -9,4 +9,4 @@ CREATE TABLE users (
|
||||
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY(`email`)
|
||||
) Engine=InnoDb;
|
||||
);
|
||||
|
@ -7,4 +7,4 @@ CREATE TABLE images (
|
||||
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY(`url`)
|
||||
) Engine=InnoDb;
|
||||
);
|
||||
|
@ -18,4 +18,4 @@ CREATE TABLE channels (
|
||||
FOREIGN KEY(`owner_id`) REFERENCES users(`id`),
|
||||
FOREIGN KEY(`image_id`) REFERENCES images(`id`),
|
||||
UNIQUE KEY(`name`)
|
||||
) Engine=InnoDb;
|
||||
);
|
||||
|
@ -17,4 +17,4 @@ CREATE TABLE episodes (
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY(`channel_id`) REFERENCES channels(`id`),
|
||||
FOREIGN KEY(`image_id`) REFERENCES images(`id`)
|
||||
) Engine=InnoDb;
|
||||
);
|
||||
|
3
sql/05-transactions.sql
Normal file
3
sql/05-transactions.sql
Normal file
@ -0,0 +1,3 @@
|
||||
CREATE TABLE `transactions` (
|
||||
|
||||
);
|
Loading…
Reference in New Issue
Block a user