mirror of
				https://github.com/slawkens/myaac.git
				synced 2025-11-04 09:46:23 +01:00 
			
		
		
		
	Refactor migrations with $up & $down
This commit is contained in:
		@@ -1,10 +1,17 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * @var OTS_DB_MySQL $db
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// add look column
 | 
			
		||||
$up = function () use ($db) {
 | 
			
		||||
	$db->exec('ALTER TABLE `' . TABLE_PREFIX . "monsters` ADD `look` VARCHAR(255) NOT NULL DEFAULT '' AFTER `health`;");
 | 
			
		||||
	if (!$db->hasColumn(TABLE_PREFIX . 'monsters', 'look')) {
 | 
			
		||||
		$db->addColumn(TABLE_PREFIX . 'monsters', 'look', "VARCHAR(255) NOT NULL DEFAULT '' AFTER `health`");
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
$down = function () use ($db) {
 | 
			
		||||
	$db->exec('ALTER TABLE `' . TABLE_PREFIX . "monsters` DROP COLUMN `look`;");
 | 
			
		||||
	if ($db->hasColumn(TABLE_PREFIX . 'monsters', 'look')) {
 | 
			
		||||
		$db->dropColumn(TABLE_PREFIX . 'monsters', 'look');
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user