Fix SQL bugs

- Fixes #117
- Fixes #116
This commit is contained in:
Matej Kramny 2016-06-02 19:26:51 +01:00
parent cafdcf2d93
commit f16b3a57e8
5 changed files with 10 additions and 8 deletions

View File

@ -31,7 +31,7 @@ func (t *task) log(msg string) {
}
go func() {
_, err := database.Mysql.Exec("insert into task__output set task_id=?, output=?, time=?", t.task.ID, msg, now)
_, err := database.Mysql.Exec("insert into task__output set task_id=?, task='', output=?, time=?", t.task.ID, msg, now)
if err != nil {
panic(err)
}

View File

@ -67,6 +67,7 @@ func (t *task) run() {
now := time.Now()
t.task.Status = "running"
t.task.Start = &now
t.updateStatus()
}

View File

@ -1,7 +1,7 @@
alter table user change `created` `created` datetime not null default current_timestamp;
alter table project change `created` `created` datetime not null default current_timestamp comment 'Created timestamp';
alter table task change `created` `created` datetime not null default current_timestamp;
alter table user__token change `created` `created` datetime not null default current_timestamp;
alter table user change `created` `created` datetime not null;
alter table project change `created` `created` datetime not null comment 'Created timestamp';
alter table task change `created` `created` datetime not null;
alter table user__token change `created` `created` datetime not null;
alter table task drop foreign key `task_ibfk_1`;
alter table task add constraint `task_ibfk_1` foreign key (`template_id`) references `project__template` (`id`) on delete cascade;

View File

@ -62,4 +62,4 @@ gox -os="linux darwin windows openbsd" -output="semaphore_{{.OS}}_{{.Arch}}" ./.
if [ "$CIRCLE_ARTIFACTS" != "" ]; then
rsync -a semaphore_* $CIRCLE_ARTIFACTS/
exit 0
fi
fi

View File

@ -13,7 +13,9 @@ type Project struct {
}
func (project *Project) CreateProject() error {
res, err := database.Mysql.Exec("insert into project set name=?", project.Name)
project.Created = time.Now()
res, err := database.Mysql.Exec("insert into project set name=?, created=?", project.Name, project.Created)
if err != nil {
return err
}
@ -24,7 +26,6 @@ func (project *Project) CreateProject() error {
}
project.ID = int(projectID)
project.Created = time.Now()
return nil
}