summaryrefslogtreecommitdiff
path: root/src/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/mysql/createTables.sql24
-rw-r--r--src/sql/mysql/updates/update_14_to_15.sql22
-rw-r--r--src/sql/mysql/updates/update_16_to_17.sql19
-rw-r--r--src/sql/sqlite/createTables.sql17
-rw-r--r--src/sql/sqlite/updates/update_14_to_15.sql21
-rw-r--r--src/sql/sqlite/updates/update_16_to_17.sql16
6 files changed, 113 insertions, 6 deletions
diff --git a/src/sql/mysql/createTables.sql b/src/sql/mysql/createTables.sql
index 3a5f5187..b75fc0ed 100644
--- a/src/sql/mysql/createTables.sql
+++ b/src/sql/mysql/createTables.sql
@@ -179,16 +179,32 @@ DEFAULT CHARSET=utf8
AUTO_INCREMENT=1 ;
--
+-- table: `mana_floor_items`
+--
+CREATE TABLE IF NOT EXISTS `mana_floor_items` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `map_id` int(10) unsigned NOT NULL,
+ `item_id` int(10) unsigned NOT NULL,
+ `amount` smallint(5) unsigned NOT NULL,
+ `pos_x` smallint(5) unsigned NOT NULL,
+ `pos_y` smallint(5) unsigned NOT NULL,
+ --
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB
+DEFAULT CHARSET=utf8
+AUTO_INCREMENT=1 ;
+
+--
-- table: `mana_char_equips`
--
CREATE TABLE IF NOT EXISTS `mana_char_equips` (
`id` int(10) unsigned NOT NULL auto_increment,
`owner_id` int(10) unsigned NOT NULL,
- `slot_type` tinyint(3) unsigned NOT NULL,
- `inventory_slot` tinyint(3) unsigned NOT NULL,
+ `slot_type` int(10) unsigned NOT NULL,
+ `item_id` int(10) unsigned NOT NULL,
+ `item_instance` int(10) unsigned NOT NULL,
--
PRIMARY KEY (`id`),
- UNIQUE KEY `owner_id` (`owner_id`, `inventory_slot`),
FOREIGN KEY (`owner_id`) REFERENCES `mana_characters` (`id`)
) ENGINE=InnoDB
DEFAULT CHARSET=utf8;
@@ -421,7 +437,7 @@ AUTO_INCREMENT=0 ;
INSERT INTO mana_world_states VALUES('accountserver_startup',NULL,NULL, NOW());
INSERT INTO mana_world_states VALUES('accountserver_version',NULL,NULL, NOW());
-INSERT INTO mana_world_states VALUES('database_version', NULL,'14', NOW());
+INSERT INTO mana_world_states VALUES('database_version', NULL,'17', NOW());
-- all known transaction codes
diff --git a/src/sql/mysql/updates/update_14_to_15.sql b/src/sql/mysql/updates/update_14_to_15.sql
new file mode 100644
index 00000000..1036817b
--- /dev/null
+++ b/src/sql/mysql/updates/update_14_to_15.sql
@@ -0,0 +1,22 @@
+
+-- Dropping the table will only unequip characters, so it's not an issue.
+DROP TABLE mana_char_equips;
+
+-- Recreate the table using the latest definition.
+CREATE TABLE IF NOT EXISTS `mana_char_equips` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `owner_id` int(10) unsigned NOT NULL,
+ `slot_type` int(10) unsigned NOT NULL,
+ `item_id` int(10) unsigned NOT NULL,
+ `item_instance` int(10) unsigned NOT NULL,
+ --
+ PRIMARY KEY (`id`),
+ FOREIGN KEY (`owner_id`) REFERENCES `mana_characters` (`id`)
+) ENGINE=InnoDB
+DEFAULT CHARSET=utf8;
+
+-- Update database version.
+UPDATE mana_world_states
+SET value = '15',
+moddate = UNIX_TIMESTAMP()
+WHERE state_name = 'database_version';
diff --git a/src/sql/mysql/updates/update_16_to_17.sql b/src/sql/mysql/updates/update_16_to_17.sql
new file mode 100644
index 00000000..008983aa
--- /dev/null
+++ b/src/sql/mysql/updates/update_16_to_17.sql
@@ -0,0 +1,19 @@
+-- Create the new floor item table
+CREATE TABLE IF NOT EXISTS `mana_floor_items` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `map_id` int(10) unsigned NOT NULL,
+ `item_id` int(10) unsigned NOT NULL,
+ `amount` smallint(5) unsigned NOT NULL,
+ `pos_x` smallint(5) unsigned NOT NULL,
+ `pos_y` smallint(5) unsigned NOT NULL,
+ --
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB
+DEFAULT CHARSET=utf8
+AUTO_INCREMENT=1 ;
+
+-- Update database version.
+UPDATE mana_world_states
+SET value = '17',
+moddate = UNIX_TIMESTAMP()
+WHERE state_name = 'database_version';
diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql
index b366606b..2d7360da 100644
--- a/src/sql/sqlite/createTables.sql
+++ b/src/sql/sqlite/createTables.sql
@@ -173,12 +173,25 @@ CREATE INDEX mana_item_attributes_item ON mana_item_attributes ( item_id );
-----------------------------------------------------------------------------
+CREATE TABLE mana_floor_items
+(
+ id INTEGER PRIMARY KEY,
+ map_id INTEGER NOT NULL,
+ item_id INTEGER NOT NULL,
+ amount INTEGER NOT NULL,
+ pos_x INTEGER NOT NULL,
+ pos_y INTEGER NOT NULL
+);
+
+-----------------------------------------------------------------------------
+
CREATE TABLE mana_char_equips
(
id INTEGER PRIMARY KEY,
owner_id INTEGER NOT NULL,
slot_type INTEGER NOT NULL,
- inventory_slot INTEGER NOT NULL,
+ item_id INTEGER NOT NULL,
+ item_instance INTEGER NOT NULL,
--
FOREIGN KEY (owner_id) REFERENCES mana_characters(id)
);
@@ -406,7 +419,7 @@ AS
INSERT INTO mana_world_states VALUES('accountserver_startup',NULL,NULL, strftime('%s','now'));
INSERT INTO mana_world_states VALUES('accountserver_version',NULL,NULL, strftime('%s','now'));
-INSERT INTO mana_world_states VALUES('database_version', NULL,'14', strftime('%s','now'));
+INSERT INTO mana_world_states VALUES('database_version', NULL,'17', strftime('%s','now'));
-- all known transaction codes
diff --git a/src/sql/sqlite/updates/update_14_to_15.sql b/src/sql/sqlite/updates/update_14_to_15.sql
new file mode 100644
index 00000000..777764d8
--- /dev/null
+++ b/src/sql/sqlite/updates/update_14_to_15.sql
@@ -0,0 +1,21 @@
+
+-- Dropping the table will only unequip characters, so it's not an issue.
+DROP TABLE mana_char_equips;
+
+-- Recreate the table using the latest definition.
+CREATE TABLE mana_char_equips
+(
+ id INTEGER PRIMARY KEY,
+ owner_id INTEGER NOT NULL,
+ slot_type INTEGER NOT NULL,
+ item_id INTEGER NOT NULL,
+ item_instance INTEGER NOT NULL,
+ --
+ FOREIGN KEY (owner_id) REFERENCES mana_characters(id)
+);
+
+-- Update the database version, and set date of update
+UPDATE mana_world_states
+ SET value = '15',
+ moddate = strftime('%s','now')
+ WHERE state_name = 'database_version';
diff --git a/src/sql/sqlite/updates/update_16_to_17.sql b/src/sql/sqlite/updates/update_16_to_17.sql
new file mode 100644
index 00000000..769c26da
--- /dev/null
+++ b/src/sql/sqlite/updates/update_16_to_17.sql
@@ -0,0 +1,16 @@
+-- Create the new floor item table
+CREATE TABLE mana_floor_items
+(
+ id INTEGER PRIMARY KEY,
+ map_id INTEGER NOT NULL,
+ item_id INTEGER NOT NULL,
+ amount INTEGER NOT NULL,
+ pos_x INTEGER NOT NULL,
+ pos_y INTEGER NOT NULL
+);
+
+-- Update the database version, and set date of update
+UPDATE mana_world_states
+ SET value = '17',
+ moddate = strftime('%s','now')
+ WHERE state_name = 'database_version';