From 4e8a73591b40b9cc249dc2420942e82e6d30d35b Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 9 Sep 2019 22:27:13 +0100 Subject: [PATCH] Set track_like date column default value --- houdini.sql | 2 ++ houdini/data/music.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/houdini.sql b/houdini.sql index 2bf2ae4..97ed636 100644 --- a/houdini.sql +++ b/houdini.sql @@ -971,6 +971,8 @@ CREATE TABLE track_like ( CREATE INDEX track_like_track_id ON track_like (track_id); +ALTER TABLE track_like ALTER COLUMN date SET DEFAULT now(); + COMMENT ON TABLE track_like IS 'SoundStudio likes'; COMMENT ON COLUMN track_like.track_id IS 'Liked track ID'; diff --git a/houdini/data/music.py b/houdini/data/music.py index f784185..ea858c2 100644 --- a/houdini/data/music.py +++ b/houdini/data/music.py @@ -1,4 +1,4 @@ -from houdini.data import db +from houdini.data import db, BaseCrumbsCollection class PenguinTrack(db.Model): @@ -19,4 +19,4 @@ class TrackLike(db.Model): nullable=False) track_id = db.Column(db.ForeignKey('penguin_track.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, nullable=False, index=True) - date = db.Column(db.DateTime, primary_key=True, nullable=False) \ No newline at end of file + date = db.Column(db.DateTime, primary_key=True, nullable=False, server_default=db.text("now()"))