bluzphp /
skeleton
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @copyright Bluz PHP Team |
||
| 4 | * @link https://github.com/bluzphp/skeleton |
||
| 5 | */ |
||
| 6 | |||
| 7 | use Phinx\Migration\AbstractMigration; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * InitDb |
||
| 11 | */ |
||
| 12 | class Initial extends AbstractMigration |
||
|
0 ignored issues
–
show
|
|||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Migrate Up. |
||
| 16 | */ |
||
| 17 | public function up() |
||
| 18 | { |
||
| 19 | $this->execute('SET storage_engine=INNODB;'); |
||
| 20 | $this->execute('CREATE TABLE users (id BIGINT(20) unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT, login VARCHAR(255), email VARCHAR(255), created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, updated TIMESTAMP NOT NULL, status VARCHAR(32) DEFAULT \'disabled\' NOT NULL);'); |
||
| 21 | $this->execute('CREATE UNIQUE INDEX users_login_uindex ON users (login);'); |
||
| 22 | $this->execute('CREATE UNIQUE INDEX users_email_uindex ON users (email);'); |
||
| 23 | $this->execute('CREATE TABLE users_actions (userId BIGINT(20) unsigned NOT NULL, code VARCHAR(32) NOT NULL, action VARCHAR(32) NOT NULL, params LONGTEXT, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, expired TIMESTAMP NOT NULL, CONSTRAINT users_actions_userId_code_pk PRIMARY KEY (userId, code), CONSTRAINT users_actions_users_id_fk FOREIGN KEY (userId) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE);'); |
||
| 24 | $this->execute('CREATE UNIQUE INDEX users_actions_userId_action_uindex ON users_actions (userId, action);'); |
||
| 25 | $this->execute('CREATE TABLE auth ( userId BIGINT(20) unsigned NOT NULL, provider VARCHAR(64) NOT NULL, foreignKey VARCHAR(255) NOT NULL, token VARCHAR(64) NOT NULL, tokenSecret VARCHAR(64) NOT NULL, tokenType VARCHAR(32) NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, updated TIMESTAMP NOT NULL, expired TIMESTAMP NOT NULL, CONSTRAINT auth_userId_provider_pk PRIMARY KEY (userId, provider), CONSTRAINT auth_users_id_fk FOREIGN KEY (userId) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE);'); |
||
| 26 | $this->execute('CREATE TABLE acl_roles ( id INT(10) unsigned NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, CONSTRAINT acl_roles_id_name_pk PRIMARY KEY (id, name));'); |
||
| 27 | $this->execute('CREATE UNIQUE INDEX acl_roles_name_uindex ON acl_roles (name);'); |
||
| 28 | $this->execute('CREATE TABLE acl_privileges ( roleId INT(10) unsigned NOT NULL, module VARCHAR(32) NOT NULL, privilege VARCHAR(32) NOT NULL, CONSTRAINT acl_privileges_acl_roles_id_fk FOREIGN KEY (roleId) REFERENCES acl_roles (id) ON DELETE CASCADE ON UPDATE CASCADE);'); |
||
| 29 | $this->execute('CREATE UNIQUE INDEX acl_privileges_roleId_module_privilege_uindex ON acl_privileges (roleId, module, privilege);'); |
||
| 30 | $this->execute('CREATE TABLE acl_users_roles ( userId BIGINT(20) unsigned NOT NULL, roleId INT(10) unsigned NOT NULL, CONSTRAINT acl_users_roles_userId_roleId_pk PRIMARY KEY (userId, roleId), CONSTRAINT acl_users_roles_users_id_fk FOREIGN KEY (userId) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT acl_users_roles_acl_roles_id_fk FOREIGN KEY (roleId) REFERENCES acl_roles (id) ON DELETE CASCADE ON UPDATE CASCADE);'); |
||
| 31 | $this->execute('CREATE TABLE pages ( id INT(10) unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT, userId BIGINT(20) unsigned, title LONGTEXT NOT NULL, alias VARCHAR(255) NOT NULL, content LONGTEXT, keywords LONGTEXT, description LONGTEXT, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, updated TIMESTAMP NOT NULL, CONSTRAINT pages_users_id_fk FOREIGN KEY (userId) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE);'); |
||
| 32 | $this->execute('CREATE UNIQUE INDEX pages_alias_uindex ON pages (alias);'); |
||
| 33 | |||
| 34 | $this->execute('LOCK TABLES `users` WRITE;'); |
||
| 35 | $this->execute('INSERT INTO `users` (`id`, `login`, `email`, `created`, `updated`, `status`) VALUES (1,\'system\',NULL,\'2012-11-09 07:37:58\',NULL,\'disabled\'), (2,\'admin\',NULL,\'2012-11-09 07:38:41\',NULL,\'active\');'); |
||
| 36 | $this->execute('UNLOCK TABLES;'); |
||
| 37 | $this->execute('LOCK TABLES `acl_roles` WRITE;'); |
||
| 38 | $this->execute('INSERT INTO `acl_roles` (`id`, `name`, `created`) VALUES (1,\'system\',\'2012-11-09 07:37:31\'), (2,\'admin\',\'2012-11-09 07:37:33\'), (3,\'member\',\'2012-11-09 07:37:37\'), (4,\'guest\',\'2012-11-09 07:37:44\');'); |
||
| 39 | $this->execute('UNLOCK TABLES;'); |
||
| 40 | $this->execute('LOCK TABLES `acl_privileges` WRITE;'); |
||
| 41 | $this->execute('INSERT INTO `acl_privileges` (`roleId`, `module`, `privilege`) VALUES (2,\'acl\',\'Management\'), (2,\'acl\',\'View\'), (2,\'cache\',\'Management\'), (2,\'dashboard\',\'Dashboard\'), (2,\'pages\',\'Management\'), (2,\'system\',\'Info\'), (2,\'users\',\'EditEmail\'), (2,\'users\',\'EditPassword\'), (2,\'users\',\'Management\'), (2,\'users\',\'ViewProfile\'), (3,\'users\',\'EditEmail\'), (3,\'users\',\'EditPassword\'), (3,\'users\',\'ViewProfile\'), (4,\'users\',\'ViewProfile\');'); |
||
| 42 | $this->execute('UNLOCK TABLES;'); |
||
| 43 | $this->execute('LOCK TABLES `acl_users_roles` WRITE;'); |
||
| 44 | $this->execute('INSERT INTO `acl_users_roles` (`userId`, `roleId`) VALUES (1,1), (2,2);'); |
||
| 45 | $this->execute('UNLOCK TABLES;'); |
||
| 46 | $this->execute('LOCK TABLES `auth` WRITE;'); |
||
| 47 | $this->execute('INSERT INTO `auth` (`userId`, `provider`, `foreignKey`, `token`, `tokenSecret`, `tokenType`, `created`) VALUES (2,\'equals\',\'admin\',\'$2y$10$4a454775178c3f89d510fud2T.xtw01Ir.Jo.91Dr3nL2sz3OyVpK\',\'\',\'access\',\'2012-11-09 07:40:46\');'); |
||
| 48 | $this->execute('UNLOCK TABLES;'); |
||
| 49 | $this->execute('LOCK TABLES `pages` WRITE;'); |
||
| 50 | $this->execute('INSERT INTO `pages` (`id`, `title`, `alias`, `content`, `keywords`, `description`, `created`, `updated`, `userId`) VALUES (1,\'About Bluz Framework\',\'about\',\'<p>Bluz Lightweight PHP Framework!</p>\',\'about bluz framework\',\'About Bluz\',\'2012-04-09 18:34:03\',\'2014-05-12 11:01:03\', 1);'); |
||
| 51 | $this->execute('UNLOCK TABLES;'); |
||
| 52 | } |
||
| 53 | /** |
||
| 54 | * Migrate Down. |
||
| 55 | */ |
||
| 56 | public function down() |
||
| 57 | { |
||
| 58 | $this->dropTable('pages'); |
||
| 59 | $this->dropTable('acl_users_roles'); |
||
| 60 | $this->dropTable('acl_privileges'); |
||
| 61 | $this->dropTable('acl_roles'); |
||
| 62 | $this->dropTable('auth'); |
||
| 63 | $this->dropTable('users_actions'); |
||
| 64 | $this->dropTable('users'); |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.