parent
77123d56b2
commit
3bdc35e197
@ -1,28 +1,32 @@
|
||||
create TABLE locations (
|
||||
CREATE TABLE locations (
|
||||
id INTEGER PRIMARY KEY,
|
||||
x INTEGER NOT NULL,
|
||||
y INTEGER NOT NULL,
|
||||
z INTEGER NOT NULL,
|
||||
world INTEGER NOT NULL
|
||||
)
|
||||
world INTEGER NOT NULL,
|
||||
observable INTEGER NOT NULL references observables(id)
|
||||
);
|
||||
|
||||
create TABLE exits (
|
||||
id INTEGER PRIMARY KEY,
|
||||
to INTEGER REFERENCES locations(id),
|
||||
from INTEGER REFERENCES locations(id)
|
||||
)
|
||||
|
||||
create TABLE observables (
|
||||
CREATE TABLE observables (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
create TABLE inventories (
|
||||
CREATE TABLE inventories (
|
||||
id INTEGER PRIMARY KEY
|
||||
)
|
||||
);
|
||||
|
||||
create TABLE pools (
|
||||
CREATE TABLE pools (
|
||||
id INTEGER PRIMARY KEY,
|
||||
type INTEGER NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE exits (
|
||||
id INTEGER PRIMARY KEY,
|
||||
origin INTEGER NOT NULL,
|
||||
dest INTEGER NOT NULL,
|
||||
FOREIGN KEY (origin) REFERENCES locations (id),
|
||||
FOREIGN KEY (dest) REFERENCES locations (id)
|
||||
);
|
||||
|
||||
@ -1,11 +1,30 @@
|
||||
-- name: CreateLocation :exec
|
||||
insert INTO LOCATIONS (x,y,z,world) VALUES (?,?,?,?);
|
||||
|
||||
-- Location
|
||||
-- name: CreateLocation :execlastid
|
||||
insert INTO locations (x,y,z,world, observable) VALUES (?,?,?,?,?);
|
||||
-- name: GetLocation :one
|
||||
select * from locations where id = ? LIMIT 1;
|
||||
-- name: UpdateLocation :exec
|
||||
update locations SET
|
||||
x = ?,
|
||||
y = ?,
|
||||
z = ?,
|
||||
world = ?,
|
||||
observable = ?
|
||||
where id = ?;
|
||||
-- name: DestroyLocation :exec
|
||||
delete from locations where id = ?;
|
||||
|
||||
-- name: GetLocationExitsTo :many
|
||||
select * from exits where to = ? LIMIT 1;
|
||||
|
||||
-- Exit
|
||||
-- name: GetExit :one
|
||||
select * from exits where id = ? LIMIT 1;
|
||||
-- name: GetLocationExitsTo :many
|
||||
select * from exits where origin = ?;
|
||||
-- name: GetLocationExitsFrom :many
|
||||
select * from exits where from = ? LIMIT 1;
|
||||
select * from exits where dest = ?;
|
||||
|
||||
-- Observable
|
||||
-- name: CreateObservable :execlastid
|
||||
insert INTO observables (name, description) VALUES (?,?);
|
||||
-- name: GetObservable :one
|
||||
select * from observables where id = ? LIMIT 1;
|
||||
|
||||
@ -1,28 +1,32 @@
|
||||
create TABLE locations (
|
||||
CREATE TABLE locations (
|
||||
id INTEGER PRIMARY KEY,
|
||||
x INTEGER NOT NULL,
|
||||
y INTEGER NOT NULL,
|
||||
z INTEGER NOT NULL,
|
||||
world INTEGER NOT NULL
|
||||
)
|
||||
world INTEGER NOT NULL,
|
||||
observable INTEGER NOT NULL references observables(id)
|
||||
);
|
||||
|
||||
create TABLE exits (
|
||||
id INTEGER PRIMARY KEY,
|
||||
to INTEGER REFERENCES locations(id),
|
||||
from INTEGER REFERENCES locations(id)
|
||||
)
|
||||
|
||||
create TABLE observables (
|
||||
CREATE TABLE observables (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
create TABLE inventories (
|
||||
CREATE TABLE inventories (
|
||||
id INTEGER PRIMARY KEY
|
||||
)
|
||||
);
|
||||
|
||||
create TABLE pools (
|
||||
CREATE TABLE pools (
|
||||
id INTEGER PRIMARY KEY,
|
||||
type INTEGER NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE exits (
|
||||
id INTEGER PRIMARY KEY,
|
||||
origin INTEGER NOT NULL,
|
||||
dest INTEGER NOT NULL,
|
||||
FOREIGN KEY (origin) REFERENCES locations (id),
|
||||
FOREIGN KEY (dest) REFERENCES locations (id)
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue