Last active
June 15, 2019 08:17
-
-
Save alvaro-canepa/03c8abc917919264f200823718387b7f to your computer and use it in GitHub Desktop.
PHP OctoberCMS Plugin Schema Create for PHPStorm file templates
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
<?php | |
#if (${NAMESPACE}) namespace ${NAMESPACE}; | |
#end | |
use Schema; | |
use October\Rain\Database\Schema\Blueprint; | |
use October\Rain\Database\Updates\Migration; | |
#parse("PHP Class Doc Comment.php") | |
class ${NAME} extends Migration | |
{ | |
protected ${DS}tablename = '${Table}'; | |
public function up() | |
{ | |
if(!Schema::hasTable(${DS}this->tablename)){ | |
Schema::create(${DS}this->tablename, function (Blueprint ${DS}table) { | |
${DS}table->engine = 'InnoDB'; | |
${DS}table->increments('id'); | |
}); | |
} | |
} | |
public function down() | |
{ | |
if(!Schema::hasTable(${DS}this->tablename)){ | |
return false; | |
} | |
Schema::dropIfExists(${DS}this->tablename); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment