Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvaro-canepa/c6fc97acbfbbeb92be3d7c2758c0b961 to your computer and use it in GitHub Desktop.
Save alvaro-canepa/c6fc97acbfbbeb92be3d7c2758c0b961 to your computer and use it in GitHub Desktop.
PHP OctoberCMS Plugin Update for PHPStorm file templates
<?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::table(${DS}this->tablename, function (Blueprint ${DS}table) {
});
}
}
public function down()
{
if(!Schema::hasTable(${DS}this->tablename)){
return false;
}
if (Schema::hasColumns(${DS}this->tablename, ['column'])) {
Schema::table(${DS}this->tablename, function (Blueprint ${DS}table) {
${DS}table->dropColumn(['column']);
}
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment