diff --git a/mapobjectdb/accessor.go b/mapobjectdb/accessor.go index 4c92b60..a4d7a96 100644 --- a/mapobjectdb/accessor.go +++ b/mapobjectdb/accessor.go @@ -18,7 +18,7 @@ type Tile struct { type MapObject struct { //mapblock position - MBPos coords.MapBlockCoords + MBPos *coords.MapBlockCoords //block position X, Y, Z int @@ -26,6 +26,7 @@ type MapObject struct { Type string Data string Mtime int64 + Attributes map[string]string } type SearchQuery struct { diff --git a/mapobjectdb/sqlite_migrate.go b/mapobjectdb/sqlite_migrate.go index 46c80d5..149e53d 100644 --- a/mapobjectdb/sqlite_migrate.go +++ b/mapobjectdb/sqlite_migrate.go @@ -8,6 +8,10 @@ import ( ) const migrateScript = ` +PRAGMA foreign_keys = ON; +PRAGMA journal_mode = MEMORY; +-- PRAGMA synchronous = OFF; + create table if not exists objects( id integer primary key autoincrement, x int, @@ -24,6 +28,14 @@ create table if not exists objects( create index if not exists objects_pos on objects(posx,posy,posz); create index if not exists objects_pos_type on objects(posx,posy,posz,type); +create table if not exists object_attributes( + id integer primary key autoincrement, + objectid integer not null, + key varchar not null, + value varchar not null, + FOREIGN KEY (objectid) references objects(id) ON DELETE CASCADE +); + create table if not exists tiles( data blob, mtime bigint, @@ -33,9 +45,6 @@ create table if not exists tiles( zoom int, primary key(x,y,zoom,layerid) ); - --- PRAGMA synchronous = OFF; --- PRAGMA journal_mode = MEMORY; ` type Sqlite3Accessor struct {