moleflap/door/createdb.lua

20 lines
740 B
Lua
Raw Normal View History

2010-02-25 08:37:50 +01:00
#!/usr/bin/env lua
require 'luasql.postgres'
require 'config'
print("* creating db ...")
2010-02-25 21:44:48 +01:00
pl = config.prefix_len
2010-02-25 08:37:50 +01:00
len = config.key_len
env = luasql.postgres()
con = env:connect(config.db)
2010-04-23 20:18:13 +02:00
assert(con:execute("create table tokens ( prefix char("..pl..") primary key, token char("..len..") unique not null, ttl int, gpg_id char(15) null);")) -- ttl - time to live
assert(con:execute("create table graveyard ( prefix char("..pl..") primary key, token char("..len..") unique not null, ttrd int, gpg_id char(15) null);")) -- ttrd - time to real death
assert(con:execute("create table users ( name text primary key, ntc int);")) -- ntc - new token count
2010-02-26 02:37:27 +01:00
assert(con:execute("create table lock (death int, host text);"))
2010-02-25 08:37:50 +01:00
con:close()
env:close()