can't be fucked to do this

This commit is contained in:
Pachira 2016-02-23 15:44:36 +01:00
parent 82b15483c3
commit 2f8a9456b4
10 changed files with 0 additions and 550 deletions

View file

@ -1,27 +0,0 @@
<?php
/**
* Holds the database migration interface.
*
* @package Sakura
*/
namespace Sakura\Migration;
/**
* Migration interface.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
interface IMigration
{
/**
* Upgrade the database to a newer version.
*/
public function up();
/**
* Downgrade the database to an older version.
*/
public function down();
}

View file

@ -1,185 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class InitialStructure implements IMigration
{
public function up()
{
// Create API key table
DB::prepare("CREATE TABLE `{prefix}apikeys` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`owner` bigint(128) unsigned NOT NULL,
`apikey` varchar(32) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create bans table
DB::prepare("CREATE TABLE `{prefix}bans` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`uid` bigint(128) unsigned NOT NULL,
`ip` varchar(255) COLLATE utf8_bin NOT NULL,
`type` tinyint(1) unsigned NOT NULL,
`timestamp` int(64) unsigned NOT NULL,
`bannedtill` int(64) unsigned NOT NULL,
`modid` bigint(128) unsigned NOT NULL,
`modip` varchar(255) COLLATE utf8_bin NOT NULL,
`reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create config table
DB::prepare("CREATE TABLE `{prefix}config` (
`config_name` varchar(255) COLLATE utf8_bin NOT NULL,
`config_value` varchar(255) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create groups table
DB::prepare("CREATE TABLE `{prefix}groups` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`groupname` varchar(255) COLLATE utf8_bin NOT NULL,
`colour` varchar(255) COLLATE utf8_bin NOT NULL,
`description` text COLLATE utf8_bin NOT NULL',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create messages table
DB::prepare("CREATE TABLE `{prefix}messages` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`fromUser` bigint(128) unsigned NOT NULL,
`toUsers` varchar(255) COLLATE utf8_bin NOT NULL,
`readBy` varchar(255) COLLATE utf8_bin NOT NULL,
`deletedBy` varchar(255) COLLATE utf8_bin NOT NULL,
`date` int(64) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_bin NOT NULL,
`content` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create news table
DB::prepare("CREATE TABLE `{prefix}news` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`uid` bigint(128) unsigned NOT NULL,
`date` int(64) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_bin NOT NULL,
`content` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create registration codes table
DB::prepare("CREATE TABLE `{prefix}regcodes` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(32) COLLATE utf8_bin NOT NULL,
`created_by` bigint(128) unsigned NOT NULL,
`used_by` bigint(128) unsigned NOT NULL,
`key_used` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create sessions table
DB::prepare("CREATE TABLE `{prefix}sessions` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`userip` varchar(255) COLLATE utf8_bin NOT NULL,
`useragent` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`userid` bigint(128) unsigned NOT NULL,
`skey` varchar(255) COLLATE utf8_bin NOT NULL,
`started` int(64) unsigned NOT NULL,
`expire` int(64) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create users table
DB::prepare("CREATE TABLE `{prefix}users` (
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE utf8_bin NOT NULL,
`username_clean` varchar(255) COLLATE utf8_bin NOT NULL,
`password_hash` varchar(255) COLLATE utf8_bin NOT NULL,
`password_salt` varchar(255) COLLATE utf8_bin NOT NULL,
`password_algo` varchar(255) COLLATE utf8_bin NOT NULL,
`password_iter` int(16) unsigned NOT NULL,
`password_chan` int(16) unsigned NOT NULL,
`password_new` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`email` varchar(32) COLLATE utf8_bin NOT NULL,
`group_main` mediumint(4) unsigned NOT NULL,
`groups` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '0',
`name_colour` varchar(255) COLLATE utf8_bin DEFAULT NULL DEFAULT '[0]',
`register_ip` varchar(16) COLLATE utf8_bin NOT NULL,
`last_ip` varchar(16) COLLATE utf8_bin NOT NULL,
`usertitle` varchar(64) COLLATE utf8_bin NOT NULL,
`profile_md` text COLLATE utf8_bin,
`avatar_url` varchar(255) COLLATE utf8_bin NOT NULL,
`background_url` varchar(255) COLLATE utf8_bin NOT NULL,
`regdate` int(16) unsigned NOT NULL DEFAULT '0',
`lastdate` int(16) unsigned NOT NULL DEFAULT '0',
`lastunamechange` int(16) unsigned NOT NULL DEFAULT '0',
`birthday` varchar(16) COLLATE utf8_bin DEFAULT NULL,
`profile_data` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username_clean` (`username_clean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create warnings table
DB::prepare("CREATE TABLE `{prefix}warnings` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`uid` bigint(128) unsigned NOT NULL,
`mod` bigint(128) unsigned NOT NULL,
`issued` int(64) unsigned NOT NULL,
`expire` int(64) unsigned NOT NULL,
`reason` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT 'Reason for the warning.',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
}
public function down()
{
// Drop API keys table
DB::prepare("DROP TABLE `{prefix}apikeys`")
->execute();
// Drop bans table
DB::prepare("DROP TABLE `{prefix}bans`")
->execute();
// Drop config table
DB::prepare("DROP TABLE `{prefix}config`")
->execute();
// Drop groups table
DB::prepare("DROP TABLE `{prefix}groups`")
->execute();
// Drop messages table
DB::prepare("DROP TABLE `{prefix}messages`")
->execute();
// Drop news table
DB::prepare("DROP TABLE `{prefix}news`")
->execute();
// Drop registration codes table
DB::prepare("DROP TABLE `{prefix}regcodes`")
->execute();
// Drop sessions table
DB::prepare("DROP TABLE `{prefix}sessions`")
->execute();
// Drop users table
DB::prepare("DROP TABLE `{prefix}users`")
->execute();
// Drop warnings table
DB::prepare("DROP TABLE `{prefix}warnings`")
->execute();
}
}

View file

@ -1,48 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class InfoPagesAndNulls implements IMigration
{
public function up()
{
// Add multi column to the groups table
DB::prepare("ALTER TABLE `{prefix}groups` ADD `multi` tinyint(1) unsigned NOT NULL DEFAULT '0'")
->execute();
// Create info pages table
DB::prepare("CREATE TABLE `{prefix}infopages` (
`shorthand` varchar(255) COLLATE utf8_bin NOT NULL,
`pagetitle` varchar(255) COLLATE utf8_bin NOT NULL,
`content` text COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Make certain fields in the users table nullable
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `usertitle` DEFAULT NULL')
->execute();
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `avatar_url` DEFAULT NULL')
->execute();
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `background_url` DEFAULT NULL')
->execute();
}
public function down()
{
// Drop the multi column from the groups table
DB::prepare("ALTER TABLE `{prefix}groups` DROP COLUMN `multi`")
->execute();
// Drop info pages table
DB::prepare("DROP TABLE `{prefix}infopages`")
->execute();
// Revert the null
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `usertitle` NOT NULL')
->execute();
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `avatar_url` NOT NULL')
->execute();
DB::prepare('ALTER TABLE `{prefix}users` MODIFY `background_url` NOT NULL')
->execute();
}
}

View file

@ -1,32 +0,0 @@
<?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();
}
}

View file

@ -1,41 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class TenshiAndProfileFields implements IMigration
{
public function up()
{
// Create the profile fields table
DB::prepare("CREATE TABLE `{prefix}profilefields` (
`id` int(64) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`formtype` varchar(255) COLLATE utf8_bin NOT NULL,
`description` varchar(255) COLLATE utf8_bin NOT NULL,
`additional` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Create the tenshi table
DB::prepare("CREATE TABLE `{prefix}tenshi` (
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`uid` bigint(255) unsigned NOT NULL,
`startdate` int(64) unsigned NOT NULL,
`expiredate` int(64) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
}
public function down()
{
// Drop the profile fields table
DB::prepare("DROP TABLE `{prefix}profilefields`")
->execute();
// Drop the tenshi table
DB::prepare("DROP TABLE `{prefix}tenshi`")
->execute();
}
}

View file

@ -1,27 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class ActionCodes implements IMigration
{
public function up()
{
// Create the profile fields table
DB::prepare("CREATE TABLE `{prefix}actioncodes` (
`id` bigint(255) NOT NULL AUTO_INCREMENT,
`action` varchar(255) COLLATE utf8_bin NOT NULL,
`userid` bigint(255) NOT NULL,
`actkey` varchar(255) COLLATE utf8_bin NOT NULL,
`instruction` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
}
public function down()
{
// Drop the profile fields table
DB::prepare("DROP TABLE `{prefix}actioncodes`")
->execute();
}
}

View file

@ -1,28 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class AddProfileFieldTypes implements IMigration
{
public function up()
{
// Add islink
DB::prepare("ALTER TABLE `{prefix}profilefields` ADD `islink` tinyint(1) unsigned NOT NULL")
->execute();
// Add linkformat
DB::prepare("ALTER TABLE `{prefix}profilefields` ADD `linkformat` varchar(255) COLLATE utf8_bin NOT NULL")
->execute();
}
public function down()
{
// Drop islink
DB::prepare("ALTER TABLE `{prefix}profilefields` DROP COLUMN `islink`")
->execute();
// Drop linkformat
DB::prepare("ALTER TABLE `{prefix}profilefields` DROP COLUMN `linkformat`")
->execute();
}
}

View file

@ -1,110 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class FaqForumAndSocks implements IMigration
{
public function up()
{
// Add faq table
DB::prepare("CREATE TABLE `{prefix}faq` (
`id` bigint(128) unsigned NOT NULL AUTO_INCREMENT,
`short` varchar(255) COLLATE utf8_bin NOT NULL,
`question` varchar(255) COLLATE utf8_bin NOT NULL,
`answer` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Add forums table
DB::prepare("CREATE TABLE `{prefix}forums` (
`forum_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`forum_name` varchar(255) COLLATE utf8_bin NOT NULL,
`forum_desc` text COLLATE utf8_bin NOT NULL,
`forum_link` varchar(255) COLLATE utf8_bin NOT NULL,
`forum_category` bigint(255) unsigned NOT NULL DEFAULT '0',
`forum_type` tinyint(4) unsigned NOT NULL DEFAULT '0',
`forum_posts` bigint(128) unsigned NOT NULL DEFAULT '0',
`forum_topics` bigint(255) unsigned NOT NULL DEFAULT '0',
`forum_last_post_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`forum_last_poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`forum_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Add posts table
DB::prepare("CREATE TABLE `{prefix}posts` (
`post_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`topic_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`forum_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`poster_ip` varchar(40) COLLATE utf8_bin NOT NULL,
`post_time` int(11) unsigned NOT NULL DEFAULT '0',
`enable_markdown` tinyint(1) unsigned NOT NULL DEFAULT '1',
`enable_sig` tinyint(1) unsigned NOT NULL DEFAULT '1',
`post_subject` varchar(255) COLLATE utf8_bin NOT NULL,
`post_text` text COLLATE utf8_bin NOT NULL,
`post_edit_time` int(11) unsigned NOT NULL DEFAULT '0',
`post_edit_reason` varchar(255) COLLATE utf8_bin NOT NULL,
`post_edit_user` int(255) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`post_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Add sock_perms table
DB::prepare("CREATE TABLE `{prefix}sock_perms` (
`rid` bigint(128) unsigned NOT NULL DEFAULT '0',
`uid` bigint(255) unsigned NOT NULL DEFAULT '0',
`perms` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '1,0,0,0,0,0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Add topics table
DB::prepare("CREATE TABLE `{prefix}topics` (
`topic_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`forum_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`topic_hidden` tinyint(1) unsigned NOT NULL DEFAULT '0',
`topic_title` varchar(255) COLLATE utf8_bin NOT NULL,
`topic_time` int(11) unsigned NOT NULL DEFAULT '0',
`topic_time_limit` int(11) unsigned NOT NULL DEFAULT '0',
`topic_last_reply` int(11) unsigned NOT NULL DEFAULT '0',
`topic_views` bigint(64) unsigned NOT NULL DEFAULT '0',
`topic_replies` bigint(128) unsigned NOT NULL DEFAULT '0',
`topic_status` tinyint(3) unsigned NOT NULL DEFAULT '0',
`topic_status_change` int(11) unsigned NOT NULL DEFAULT '0',
`topic_type` tinyint(3) unsigned NOT NULL DEFAULT '0',
`topic_first_post_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`topic_first_poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`topic_last_post_id` bigint(255) unsigned NOT NULL DEFAULT '0',
`topic_last_poster_id` bigint(255) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`topic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Change mod to iid in warnings table
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `mod` `iid` bigint(128)')
->execute();
}
public function down()
{
// Drop the faq table
DB::prepare("DROP TABLE `{prefix}faq`")->execute();
// Drop the forums table
DB::prepare("DROP TABLE `{prefix}forums`")->execute();
// Drop the posts table
DB::prepare("DROP TABLE `{prefix}posts`")->execute();
// Drop the sock_perms table
DB::prepare("DROP TABLE `{prefix}sock_perms`")->execute();
// Drop the topics table
DB::prepare("DROP TABLE `{prefix}topics`")->execute();
// Change iid to mod in warnings table
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `iid` `mod` bigint(128)')
->execute();
}
}

View file

@ -1,38 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
class NotificationsTable implements IMigration
{
public function up()
{
// Add notifications table
DB::prepare("CREATE TABLE `{prefix}notifications` (
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`uid` bigint(255) unsigned NOT NULL DEFAULT '0',
`timestamp` int(11) unsigned NOT NULL DEFAULT '0',
`notif_read` tinyint(1) unsigned NOT NULL DEFAULT '0',
`notif_title` varchar(255) COLLATE utf8_bin NOT NULL,
`notif_text` varchar(255) COLLATE utf8_bin NOT NULL,
`notif_link` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`notif_img` varchar(255) COLLATE utf8_bin NOT NULL,
`notif_timeout` int(16) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")
->execute();
// Change mod to iid in warnings table
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `mod` `iid` bigint(128)')
->execute();
}
public function down()
{
// Drop the notifications table
DB::prepare("DROP TABLE `{prefix}notifications`")->execute();
// Change iid to mod in warnings table
DB::prepare('ALTER TABLE `{prefix}warnings` CHANGE `iid` `mod` bigint(128)')
->execute();
}
}

View file

@ -1,14 +0,0 @@
<?php
use Sakura\Migration\IMigration;
use Sakura\DB;
//https://github.com/flashwave/sakura/commit/0264bbd574ff5a0e701b4331e1fbf55ca3d95ee0
class BreadOfTheFuture implements IMigration
{
public function up()
{
}
public function down()
{
}
}