-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from cakephp/plugin-snapshot
Fix baking a plugin snapshot
- Loading branch information
Showing
9 changed files
with
368 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
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
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
83 changes: 83 additions & 0 deletions
83
tests/comparisons/Migration/pgsql/test_plugin_blog_pgsql.php
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,83 @@ | ||
<?php | ||
use Migrations\AbstractMigration; | ||
|
||
class TestPluginBlogPgsql extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$table = $this->table('articles'); | ||
$table | ||
->addColumn('title', 'string', [ | ||
'comment' => 'Article title', | ||
'default' => 'NULL::character varying', | ||
'limit' => 255, | ||
'null' => true, | ||
]) | ||
->addColumn('category_id', 'integer', [ | ||
'default' => null, | ||
'limit' => 10, | ||
'null' => true, | ||
]) | ||
->addColumn('product_id', 'integer', [ | ||
'default' => null, | ||
'limit' => 10, | ||
'null' => true, | ||
]) | ||
->addColumn('created', 'timestamp', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addColumn('modified', 'timestamp', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addIndex( | ||
[ | ||
'category_id', | ||
] | ||
) | ||
->addIndex( | ||
[ | ||
'product_id', | ||
] | ||
) | ||
->create(); | ||
|
||
$this->table('articles') | ||
->addForeignKey( | ||
'category_id', | ||
'categories', | ||
'id', | ||
[ | ||
'update' => 'CASCADE', | ||
'delete' => 'CASCADE' | ||
] | ||
) | ||
->addForeignKey( | ||
'product_id', | ||
'products', | ||
'id', | ||
[ | ||
'update' => 'CASCADE', | ||
'delete' => 'CASCADE' | ||
] | ||
) | ||
->update(); | ||
|
||
} | ||
|
||
public function down() | ||
{ | ||
$this->table('articles') | ||
->dropForeignKey( | ||
'category_id' | ||
) | ||
->dropForeignKey( | ||
'product_id' | ||
); | ||
|
||
$this->dropTable('articles'); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
tests/comparisons/Migration/sqlite/test_plugin_blog_sqlite.php
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,82 @@ | ||
<?php | ||
use Migrations\AbstractMigration; | ||
|
||
class TestPluginBlogSqlite extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$table = $this->table('articles'); | ||
$table | ||
->addColumn('title', 'string', [ | ||
'default' => null, | ||
'limit' => 255, | ||
'null' => true, | ||
]) | ||
->addColumn('category_id', 'integer', [ | ||
'default' => null, | ||
'limit' => 11, | ||
'null' => true, | ||
]) | ||
->addColumn('product_id', 'integer', [ | ||
'default' => null, | ||
'limit' => 11, | ||
'null' => true, | ||
]) | ||
->addColumn('created', 'timestamp', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addColumn('modified', 'timestamp', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addIndex( | ||
[ | ||
'category_id', | ||
] | ||
) | ||
->addIndex( | ||
[ | ||
'product_id', | ||
] | ||
) | ||
->create(); | ||
|
||
$this->table('articles') | ||
->addForeignKey( | ||
'category_id', | ||
'categories', | ||
'id', | ||
[ | ||
'update' => 'CASCADE', | ||
'delete' => 'CASCADE' | ||
] | ||
) | ||
->addForeignKey( | ||
'product_id', | ||
'products', | ||
'id', | ||
[ | ||
'update' => 'CASCADE', | ||
'delete' => 'CASCADE' | ||
] | ||
) | ||
->update(); | ||
|
||
} | ||
|
||
public function down() | ||
{ | ||
$this->table('articles') | ||
->dropForeignKey( | ||
'category_id' | ||
) | ||
->dropForeignKey( | ||
'product_id' | ||
); | ||
|
||
$this->dropTable('articles'); | ||
} | ||
} |
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,83 @@ | ||
<?php | ||
use Migrations\AbstractMigration; | ||
|
||
class TestPluginBlog extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$table = $this->table('articles'); | ||
$table | ||
->addColumn('title', 'string', [ | ||
'comment' => 'Article title', | ||
'default' => null, | ||
'limit' => 255, | ||
'null' => true, | ||
]) | ||
->addColumn('category_id', 'integer', [ | ||
'default' => null, | ||
'limit' => 11, | ||
'null' => true, | ||
]) | ||
->addColumn('product_id', 'integer', [ | ||
'default' => null, | ||
'limit' => 11, | ||
'null' => true, | ||
]) | ||
->addColumn('created', 'timestamp', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addColumn('modified', 'timestamp', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addIndex( | ||
[ | ||
'category_id', | ||
] | ||
) | ||
->addIndex( | ||
[ | ||
'product_id', | ||
] | ||
) | ||
->create(); | ||
|
||
$this->table('articles') | ||
->addForeignKey( | ||
'category_id', | ||
'categories', | ||
'id', | ||
[ | ||
'update' => 'CASCADE', | ||
'delete' => 'CASCADE' | ||
] | ||
) | ||
->addForeignKey( | ||
'product_id', | ||
'products', | ||
'id', | ||
[ | ||
'update' => 'CASCADE', | ||
'delete' => 'CASCADE' | ||
] | ||
) | ||
->update(); | ||
|
||
} | ||
|
||
public function down() | ||
{ | ||
$this->table('articles') | ||
->dropForeignKey( | ||
'category_id' | ||
) | ||
->dropForeignKey( | ||
'product_id' | ||
); | ||
|
||
$this->dropTable('articles'); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
namespace Pluginapp\Model\Entity; | ||
|
||
use Cake\ORM\Entity; | ||
|
||
/** | ||
* Article Entity. | ||
* | ||
* @property int $id | ||
* @property string $title | ||
* @property string $content | ||
*/ | ||
class Article extends Entity | ||
{ | ||
|
||
/** | ||
* Fields that can be mass assigned using newEntity() or patchEntity(). | ||
* | ||
* Note that when '*' is set to true, this allows all unspecified fields to | ||
* be mass assigned. For security purposes, it is advised to set '*' to false | ||
* (or remove it), and explicitly make individual fields accessible as needed. | ||
* | ||
* @var array | ||
*/ | ||
protected $_accessible = [ | ||
'*' => true, | ||
'id' => false, | ||
]; | ||
} |
Oops, something went wrong.