Rename movies colums

This commit is contained in:
Nicolas Duhamel 2016-02-24 14:04:52 +01:00
parent bdb608ae6e
commit 049c3b208c
2 changed files with 23 additions and 9 deletions

View File

@ -11,13 +11,27 @@ import (
const (
addMovieQuery = `
INSERT INTO movies (imdbid, title, rating, votes, plot, tmdbid, year, originaltitle, runtime, sorttitle, tagline)
INSERT INTO movies (imdb_id, title, rating, votes, plot, tmdb_id, year, original_title, runtime, sort_title, tagline)
VALUES (:imdbid, :title, :rating, :votes, :plot, :tmdbid, :year, :originaltitle, :runtime, :sorttitle, :tagline)
RETURNING id;`
getMovieQueryByImdbID = `SELECT * FROM movies WHERE imdbid=$1;`
getMovieQueryByID = `SELECT * FROM movies WHERE id=$1;`
deleteMovieQuery = `DELETE FROM movies WHERE id=$1;`
getMovieQueryByImdbID = `
SELECT
id, imdb_id AS imdbid, title, rating, votes, plot,
tmdb_id AS tmdbid, year,
original_title AS originaltitle, runtime,
sort_title AS sorttitle, tagline,
created_at, updated_at
FROM movies WHERE imdb_id=$1;`
getMovieQueryByID = `
SELECT
id, imdb_id AS imdbid, title, rating, votes, plot,
tmdb_id AS tmdbid, year,
original_title AS originaltitle, runtime,
sort_title AS sorttitle, tagline,
created_at, updated_at
FROM movies WHERE id=$1;`
deleteMovieQuery = `DELETE FROM movies WHERE id=$1;`
)
var (

View File

@ -72,18 +72,18 @@ CREATE INDEX ON shows_tracked (user_id);
CREATE TABLE movies (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
imdbid text NOT NULL UNIQUE,
imdb_id text NOT NULL UNIQUE,
title text NOT NULL,
rating real NOT NULL,
votes integer NOT NULL,
plot text NOT NULL,
tmdbid integer NOT NULL,
tmdb_id integer NOT NULL,
year smallint NOT NULL,
originaltitle text NOT NULL,
original_title text NOT NULL,
runtime integer NOT NULL,
sorttitle text NOT NULL,
sort_title text NOT NULL,
tagline text NOT NULL,
LIKE base INCLUDING DEFAULTS
);
CREATE INDEX ON movies (imdbid);
CREATE INDEX ON movies (imdb_id);
CREATE TRIGGER update_movies_updated_at BEFORE UPDATE ON movies FOR EACH ROW EXECUTE PROCEDURE update_modified_column();