-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added sample command, and post composer commands
- Loading branch information
Showing
6 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace flight\commands; | ||
|
||
use flight\database\PdoWrapper; | ||
|
||
class SampleDatabaseCommand extends AbstractBaseCommand | ||
{ | ||
/** | ||
* Construct | ||
* | ||
* @param array<string,mixed> $config JSON config from .runway-config.json | ||
*/ | ||
public function __construct(array $config) | ||
{ | ||
parent::__construct('init:sample-db', 'Creates a sample SQLite database and tables.', $config); | ||
} | ||
|
||
/** | ||
* Executes the function | ||
* | ||
* @return void | ||
*/ | ||
public function execute() | ||
{ | ||
$io = $this->app()->io(); | ||
|
||
$PdoWrapper = new PdoWrapper('sqlite:'. __DIR__ . '/../database.sqlite'); | ||
|
||
$io->info('Creating tables...'); | ||
$PdoWrapper->exec('CREATE TABLE IF NOT EXISTS posts (id INTEGER PRIMARY KEY, title TEXT, content TEXT, username TEXT, created_at TEXT, updated_at TEXT)'); | ||
$PdoWrapper->exec('CREATE TABLE IF NOT EXISTS comments (id INTEGER PRIMARY KEY, post_id INTEGER, username TEXT, content TEXT, created_at TEXT, updated_at TEXT)'); | ||
$io->ok('Tables created!', true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters