From 3d30bfd69deb172a5843296370ed37daaefcff2f Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 26 Sep 2021 07:45:29 -0500 Subject: [PATCH] media assets: add duration column. Add a column for tracking the duration (length) of videos and animations. The duration will be null for static images. --- .../20210926123414_add_duration_to_media_assets.rb | 6 ++++++ db/structure.sql | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20210926123414_add_duration_to_media_assets.rb diff --git a/db/migrate/20210926123414_add_duration_to_media_assets.rb b/db/migrate/20210926123414_add_duration_to_media_assets.rb new file mode 100644 index 000000000..5f9429493 --- /dev/null +++ b/db/migrate/20210926123414_add_duration_to_media_assets.rb @@ -0,0 +1,6 @@ +class AddDurationToMediaAssets < ActiveRecord::Migration[6.1] + def change + add_column :media_assets, :duration, :float, null: true, default: nil, if_not_exists: true + add_index :media_assets, :duration, where: "duration IS NOT NULL" + end +end diff --git a/db/structure.sql b/db/structure.sql index 2d75152d9..93f5a42f7 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2473,7 +2473,8 @@ CREATE TABLE public.media_assets ( file_ext character varying NOT NULL, file_size integer NOT NULL, image_width integer NOT NULL, - image_height integer NOT NULL + image_height integer NOT NULL, + duration double precision ); @@ -7156,6 +7157,13 @@ CREATE INDEX index_ip_geolocations_on_updated_at ON public.ip_geolocations USING CREATE INDEX index_media_assets_on_created_at ON public.media_assets USING btree (created_at); +-- +-- Name: index_media_assets_on_duration; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_media_assets_on_duration ON public.media_assets USING btree (duration) WHERE (duration IS NOT NULL); + + -- -- Name: index_media_assets_on_file_ext; Type: INDEX; Schema: public; Owner: - -- @@ -8429,6 +8437,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20210901230931'), ('20210908015203'), ('20210921164936'), -('20210921170444'); +('20210921170444'), +('20210926123414');