Skip to content

Commit

Permalink
add executable jpetl ddl
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuck committed Oct 13, 2016
1 parent f9c058b commit 06ae305
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
29 changes: 29 additions & 0 deletions bin/jpetl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
require_once __DIR__.'/../vendor/autoload.php';
use jpuck\etl\Sources\DBMS\MicrosoftSQLServer;
use jpuck\etl\Schemata\Schema;

if(empty($argv[1])){
throw new InvalidArgumentException('Command required.');
}

if('ddl' !== $argv[1]){
throw new InvalidArgumentException('Only ddl command currently supported.');
}

if(empty($argv[2])){
throw new InvalidArgumentException('Schema required.');
}
$schema = $argv[2];

$db = new MicrosoftSQLServer(null,['stage' => false]);

// if array
if('php' === substr(strrchr($argv[2], '.'), 1)){
$schema = require $schema;
} else {
$schema = file_get_contents($schema);
}

echo $db->generate(new Schema($schema));
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
},
"require-dev": {
"phpunit/phpunit": "^5.5"
}
},
"bin": ["bin/jpetl"]
}

0 comments on commit 06ae305

Please sign in to comment.