Esempio n. 1
0
func (d *database) initTopics() {
	gox.MustExecSQL(d.DB, `create table if not exists topics(
	id bigint primary key,
	user_id bigint not null,
	channel_id bigint not null,
	content varchar(512) not null,
	created_at bigint not null,
	commented_at bigint not null default 0,
	status tinyint not null default 0,
	types varchar(50) not null default '',
	tags varchar(255) not null default '',
	at_user_ids varchar(512) not null default '',
	location varchar(255) not null default '',
	lat double not null default 0,
	lng double not null default 0,
	index user_id_idx(user_id),
	index channel_id_idx(channel_id),
	index created_at_idx(created_at),
	index commented_at_idx(commented_at),
	index status_idx(status)
	)`)

	gox.MustExecSQL(d.DB, `create table if not exists topic_actions(
	topic_id bigint,
	user_id bigint,
	action int,
	created_at bigint not null default 0,
	primary key(topic_id, user_id),
	index  created_at_idx(created_at))`)
}
Esempio n. 2
0
func (d *database) initDevices() {
	gox.MustExecSQL(d.DB, `create table if not exists devices(
	token char(64) primary key,
	user_id bigint unique,
	badge int not null default 0,
	created_at bigint not null);`)
}
Esempio n. 3
0
func (d *database) initChannels() {
	gox.MustExecSQL(d.DB, `create table if not exists channels(
	id bigint primary key,
	image varchar(255) not null default '',
	wiki varchar(255) not null default '',
	name varchar(24) not null,
	rank int not null default 0,
	status tinyint not null default 0
	)`)
}
Esempio n. 4
0
func (d *database) initNotices() {
	gox.MustExecSQL(d.DB, `create table if not exists notices(id bigint primary key,
	user_id bigint not null,
	type tinyint not null,
	content_id bigint not null,
	content varchar(10240),
	title varchar(100),
	total_count int not null default 0,
	new_count int not null default 0,
	updated_at bigint not null,
	unique(user_id, type, content_id))`)
}
Esempio n. 5
0
func newDatabase(db *sql.DB) *database {
	d := &database{db}
	gox.MustExecSQL(db, `create table if not exists albums(
	id varchar(40) primary key,
	type tinyint not null,
	content varchar(512) not null default '',
	created_at bigint not null,
	album_id bigint not null default 0,
	album_type int not null default 0)`)

	return d
}
Esempio n. 6
0
func (d *database) initComments() {
	gox.MustExecSQL(d.DB, `create table if not exists comments(id bigint primary key,
	user_id bigint not null,
	item_id bigint not null,
	item_type tinyint not null default 0,
	to_comment_id bigint not null default 0,
	content varchar(512) not null default '',
	created_at bigint not null,
	status tinyint not null default 0,
	floor int not null,
	at_user_ids varchar(512) not null default '',
	location varchar(100) not null default '',
	lat double not null default 0,
	lng double not null default 0,
	index item_idx(item_id, item_type),
	index to_id_idx(to_comment_id),
	index created_at_idx(created_at),
	index status_idx(status),
	unique(item_id,item_type,floor)
	)`)

}