Skip to content

Commit

Permalink
Fix SQL
Browse files Browse the repository at this point in the history
- for strict mode
  • Loading branch information
matejkramny committed Apr 29, 2016
1 parent 697e456 commit 4158aaa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions database/sql_migrations/v0.0.0.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
create table user (
`id` int(11) not null auto_increment primary key,
`created` datetime not null default NOW(),
`created` datetime not null,
`username` varchar(255) not null comment "Username, unique",
`name` varchar(255) not null comment "Full name",
`email` varchar(255) not null comment "Email, unique",
Expand All @@ -12,7 +12,7 @@ create table user (

create table project (
`id` int(11) not null auto_increment primary key,
`created` datetime not null default NOW() comment "Created timestamp",
`created` datetime not null comment "Created timestamp",
`name` varchar(255) not null comment "Project name"
) ENGINE=InnoDB CHARSET=utf8;

Expand Down Expand Up @@ -104,7 +104,7 @@ create table task (
create table task__output (
`task_id` int(11) not null,
`task` varchar(255) not null,
`time` datetime not null default NOW(),
`time` datetime not null,
`output` longtext not null,

unique key `id` (`task_id`, `time`),
Expand Down
2 changes: 1 addition & 1 deletion database/sql_migrations/v1.2.0.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
create table `user__token` (
`id` varchar(32) not null primary key,
`created` datetime not null default NOW(),
`created` datetime not null,
`expired` tinyint(1) not null default 0,
`user_id` int(11) not null,

Expand Down
2 changes: 1 addition & 1 deletion database/sql_migrations/v1.4.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ CREATE TABLE `event` (
KEY `created` (`created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

alter table task add `created` datetime not null default CURRENT_TIMESTAMP,
alter table task add `created` datetime not null,
add `start` datetime null,
add `end` datetime null;
2 changes: 1 addition & 1 deletion routes/projects/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func AddProject(c *gin.Context) {
panic(err)
}

if _, err := database.Mysql.Exec("insert into project__user set project_id=?, user_id=?, admin=1", body.ID, user.ID); err != nil {
if _, err := database.Mysql.Exec("insert into project__user set project_id=?, user_id=?, admin=1, created=NOW()", body.ID, user.ID); err != nil {
panic(err)
}

Expand Down
3 changes: 3 additions & 0 deletions routes/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package routes

import (
"database/sql"
"time"

"github.com/ansible-semaphore/semaphore/database"
"github.com/ansible-semaphore/semaphore/models"
Expand All @@ -25,6 +26,8 @@ func addUser(c *gin.Context) {
return
}

user.Created = time.Now()

if err := database.Mysql.Insert(&user); err != nil {
panic(err)
}
Expand Down

0 comments on commit 4158aaa

Please sign in to comment.