CREATE SEQUENCE group_seq INCREMENT 1;

CREATE TABLE "group"
(
	name VARCHAR(64) NOT NULL,
	type VARCHAR(32) NOT NULL,
	value SMALLINT NOT NULL
);
ALTER TABLE "group" ADD CONSTRAINT pkgroup
	PRIMARY KEY (type);

CREATE SEQUENCE user_seq INCREMENT 1;

CREATE TABLE user
(
	active SMALLINT NULL,
	count_logins INTEGER NOT NULL DEFAULT 0,
	description TEXT NULL,
	gender VARCHAR(1) NOT NULL DEFAULT 'n',
	id VARCHAR(32) NOT NULL,
	inserted INTEGER NOT NULL,
	last_login INTEGER NULL,
	mail VARCHAR(255) NOT NULL,
	modified INTEGER NULL,
	passwort VARCHAR(128) NOT NULL,
	permission TEXT NULL,
	photo VARCHAR(255) NULL,
	photo_active SMALLINT NULL DEFAULT 0,
	type VARCHAR(32) NOT NULL
);
ALTER TABLE user ADD CONSTRAINT pkuser
	PRIMARY KEY (id);
	
CREATE SEQUENCE newuser_seq INCREMENT 1;

CREATE TABLE newuser
(
	newuser_id INTEGER NOT NULL DEFAULT nextval('newuser_seq'),
	newuser_key TEXT NOT NULL,
	newuser_mail VARCHAR(255) NOT NULL,
	newuser_name VARCHAR(32) NOT NULL,
	newuser_utc INTEGER NOT NULL DEFAULT 0,
	newuser_ip VARCHAR(15) NOT NULL
);
ALTER TABLE newuser ADD CONSTRAINT pknewuser
	PRIMARY KEY (newuser_id);