media assets: add file_key, is_public columns.
`file_key` is a random 9-character base-62 string that will be used as the image filename in the future. `is_public` is whether the image can be viewed without authentication or not. Users running downstream boorus must run `bin/rails db:migrate` and `script/fixes/109_generate_media_asset_file_keys.rb` after this commit.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class AddFileKeyToMediaAssets < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :media_assets, :file_key, :string, null: true
|
||||
add_column :media_assets, :is_public, :boolean, default: true, null: false
|
||||
|
||||
add_index :media_assets, :file_key, unique: true
|
||||
add_index :media_assets, :is_public, where: "is_public = FALSE"
|
||||
end
|
||||
end
|
||||
@@ -1102,7 +1102,9 @@ CREATE TABLE public.media_assets (
|
||||
image_width integer NOT NULL,
|
||||
image_height integer NOT NULL,
|
||||
duration double precision,
|
||||
status integer DEFAULT 200 NOT NULL
|
||||
status integer DEFAULT 200 NOT NULL,
|
||||
file_key character varying,
|
||||
is_public boolean DEFAULT true NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -3805,6 +3807,13 @@ CREATE INDEX index_media_assets_on_duration ON public.media_assets USING btree (
|
||||
CREATE INDEX index_media_assets_on_file_ext ON public.media_assets USING btree (file_ext);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_media_assets_on_file_key; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_media_assets_on_file_key ON public.media_assets USING btree (file_key);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_media_assets_on_file_size; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3826,6 +3835,13 @@ CREATE INDEX index_media_assets_on_image_height ON public.media_assets USING btr
|
||||
CREATE INDEX index_media_assets_on_image_width ON public.media_assets USING btree (image_width);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_media_assets_on_is_public; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_media_assets_on_is_public ON public.media_assets USING btree (is_public) WHERE (is_public = false);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_media_assets_on_md5; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -5806,6 +5822,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20220403042706'),
|
||||
('20220403220558'),
|
||||
('20220407203236'),
|
||||
('20220410050628');
|
||||
('20220410050628'),
|
||||
('20220504235329');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user