Skip to content

Commit

Permalink
Change the column type of created_at/updated_at to DATETIME(MySQL,SQL…
Browse files Browse the repository at this point in the history
…ite3)/TIME(PostgreSQL).
  • Loading branch information
fukamachi committed Aug 29, 2016
1 parent 7c99c00 commit 68c27e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/core/class/column.lisp
Expand Up @@ -142,4 +142,6 @@
(:method (column (driver-type (eql :postgres)))
(let ((column-info (table-column-info column driver-type)))
(setf (getf (cdr column-info) :auto-increment) nil)
(when (eq (getf (cdr column-info) :type) :datetime)
(setf (getf (cdr column-info) :type) :time))
column-info)))
4 changes: 2 additions & 2 deletions src/core/dao/mixin.lisp
Expand Up @@ -34,7 +34,7 @@
(eql (object-id object1) (object-id object2)))))

(defclass record-timestamps-mixin ()
((created-at :col-type (or :timestamp :null)
((created-at :col-type (or :datetime :null)
:initarg :created-at
:inflate (lambda (value)
(etypecase value
Expand All @@ -44,7 +44,7 @@
(local-time:parse-timestring value :date-time-separator #\Space))
(null nil)))
:accessor object-created-at)
(updated-at :col-type (or :timestamp :null)
(updated-at :col-type (or :datetime :null)
:initarg :updated-at
:inflate (lambda (value)
(etypecase value
Expand Down
8 changes: 4 additions & 4 deletions t/class.lisp
Expand Up @@ -124,7 +124,7 @@
"CREATE TABLE tweet (
status TEXT NOT NULL,
user INTEGER NOT NULL,
created_at DATETIME NOT NULL,
created_at TIME NOT NULL,
PRIMARY KEY (user, created_at)
)"
"PRIMARY KEY")
Expand All @@ -138,7 +138,7 @@
"CREATE TABLE tweet (
status TEXT NOT NULL,
user INTEGER NOT NULL,
created_at DATETIME NOT NULL,
created_at TIME NOT NULL,
UNIQUE (user, created_at)
)"
"UNIQUE KEY")
Expand All @@ -152,7 +152,7 @@
'("CREATE TABLE tweet (
status TEXT NOT NULL,
user INTEGER NOT NULL,
created_at DATETIME NOT NULL
created_at TIME NOT NULL
)" "CREATE INDEX key_tweet_user_created_at ON tweet (user, created_at)")
"KEY")
(is-table-class :postgres
Expand All @@ -164,7 +164,7 @@
"CREATE TABLE tweet (
status TEXT NOT NULL,
user INTEGER NOT NULL,
created_at DATETIME
created_at TIME
)"
"NULL"))

Expand Down

0 comments on commit 68c27e3

Please sign in to comment.