This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/migrations/2015_04_06_200332_rename_groups_to_ranks.php

33 lines
1 KiB
PHP
Raw Normal View History

2016-02-19 21:49:00 +00:00
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class RenameGroupsToRanks implements IMigration
{
public function up()
{
// Rename groups table to ranks
DB::prepare("RENAME TABLE `{prefix}groups` TO `{prefix}ranks`")
->execute();
// Rename group* columns to rank* in the users table
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `group_main` `rank_main` mediumint(4)')
->execute();
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `groups` `ranks` varchar(255)')
->execute();
}
public function down()
{
// Rename ranks table to groups
DB::prepare("RENAME TABLE `{prefix}ranks` TO `{prefix}groups`")
->execute();
// Rename rank* columns to group* in the users table
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `rank_main` `group_main` mediumint(4)')
->execute();
DB::prepare('ALTER TABLE `{prefix}users` CHANGE `ranks` `groups` varchar(255)')
->execute();
}
}