forked from MTSR/mapserver
postgres stub
This commit is contained in:
parent
c80a9140e9
commit
52b29dbd47
13
server/db/postgres/initialblocks.go
Normal file
13
server/db/postgres/initialblocks.go
Normal file
@ -0,0 +1,13 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"mapserver/settings"
|
||||
"mapserver/layer"
|
||||
"mapserver/db"
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers []*layer.Layer, limit int) (*db.InitialBlocksResult, error) {
|
||||
return nil, nil
|
||||
}
|
@ -3,9 +3,8 @@ package postgres
|
||||
import (
|
||||
"database/sql"
|
||||
"mapserver/coords"
|
||||
"mapserver/settings"
|
||||
"mapserver/layer"
|
||||
"mapserver/db"
|
||||
"mapserver/vfs"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
@ -26,7 +25,7 @@ func (db *PostgresAccessor) Migrate() error {
|
||||
if !hasMtime {
|
||||
log.Info("Migrating database")
|
||||
start := time.Now()
|
||||
_, err = db.db.Exec(migrateScript)
|
||||
_, err = db.db.Exec(vfs.FSMustString(false, "/sql/postgres_mapdb_migrate.sql"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -70,10 +69,6 @@ func (this *PostgresAccessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db
|
||||
return blocks, nil
|
||||
}
|
||||
|
||||
func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers []*layer.Layer, limit int) (*db.InitialBlocksResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (this *PostgresAccessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
||||
rows, err := this.db.Query(countBlocksQuery, frommtime, tomtime)
|
||||
if err != nil {
|
||||
|
@ -1,25 +1,5 @@
|
||||
package postgres
|
||||
|
||||
const migrateScript = `
|
||||
alter table blocks add column mtime bigint not null default 0;
|
||||
|
||||
create index BLOCKS_TIME on blocks(mtime);
|
||||
|
||||
create or replace function on_blocks_change() returns trigger as
|
||||
$BODY$
|
||||
BEGIN
|
||||
NEW.mtime = floor(EXTRACT(EPOCH from now()) * 1000);
|
||||
return NEW;
|
||||
END;
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
create trigger blocks_update
|
||||
before insert or update
|
||||
on blocks
|
||||
for each row
|
||||
execute procedure on_blocks_change();
|
||||
`
|
||||
|
||||
const getBlocksByMtimeQuery = `
|
||||
select posx,posy,posz,data,mtime
|
||||
|
18
server/static/sql/postgres_mapdb_migrate.sql
Normal file
18
server/static/sql/postgres_mapdb_migrate.sql
Normal file
@ -0,0 +1,18 @@
|
||||
alter table blocks add column mtime bigint not null default 0;
|
||||
|
||||
create index BLOCKS_TIME on blocks(mtime);
|
||||
|
||||
create or replace function on_blocks_change() returns trigger as
|
||||
$BODY$
|
||||
BEGIN
|
||||
NEW.mtime = floor(EXTRACT(EPOCH from now()) * 1000);
|
||||
return NEW;
|
||||
END;
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
create trigger blocks_update
|
||||
before insert or update
|
||||
on blocks
|
||||
for each row
|
||||
execute procedure on_blocks_change();
|
Loading…
Reference in New Issue
Block a user