PHP code example of semisedlak / migratte
1. Go to this page and download the library: Download semisedlak/migratte library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
semisedlak / migratte example snippets
'timezone' => 'UTC',
'migrationsDir' => "$workingDir/database/migrations",
'migrationsTable' => [
'name' => 'migrations',
'primaryKey' => 'id',
'fileName' => 'filename',
'groupNo' => 'group',
'committedAt' => 'committed_at',
],
'connection' => [
'driver' => 'sqlite', // mysqli or postgre
'database' => "$workingDir/database/migratte.s3db",
],
#!/usr/bin/env php
use Semisedlak\Migratte\Application\Application;
use Semisedlak\Migratte\Migrations\Migration;
class Migration_20190101_120000 extends Migration
{
public static function getName(): string
{
return 'Create users table';
}
public static function up(): string
{
return <<<SQL
-- UP: Create users table
SQL;
}
public static function down(): ?string
{
return NULL;
}
}
public static function up(): string
{
return <<<SQL
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(255) NOT NULL
) ENGINE='InnoDB' COLLATE 'utf8mb4_general_ci';
SQL;
}
public static function down(): ?string
{
return <<<SQL
DROP TABLE `users`;
SQL;
}
// use Semisedlak\Migratte\Migrations\Application; // OLD NAMESPACE
use Semisedlak\Migratte\Application\Application; // NEW NAMESPACE