diff --git a/migrations/000002_add_movies_check_constraint.down.sql b/migrations/000002_add_movies_check_constraint.down.sql new file mode 100644 index 0000000..a60809f --- /dev/null +++ b/migrations/000002_add_movies_check_constraint.down.sql @@ -0,0 +1,3 @@ +ALTER TABLE movies DROP CONSTRAINT IF EXISTS movies_runtime_check; +ALTER TABLE movies DROP CONSTRAINT IF EXISTS movies_year_check; +ALTER TABLE movies DROP CONSTRAINT IF EXISTS genres_check_check; \ No newline at end of file diff --git a/migrations/000002_add_movies_check_constraint.up.sql b/migrations/000002_add_movies_check_constraint.up.sql new file mode 100644 index 0000000..24f487b --- /dev/null +++ b/migrations/000002_add_movies_check_constraint.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE movies ADD CONSTRAINT movies_runtime_check CHECK (runtime >= 0); +ALTER TABLE movies ADD CONSTRAINT movies_year_check CHECK (year BETWEEN 1888 and date_part('year', now())); +ALTER TABLE movies ADD CONSTRAINT genres_check_check CHECK (array_length(genres, 1) BETWEEN 1 AND 5); \ No newline at end of file