Commit 3eb8fead authored by hellekin's avatar hellekin

Set default type on imported Resources

Resource.type should not be nil, so reset it to the default 'Resource'
and add some specification to ensure it is set.
parent 1f4a2130
class UpdateResourceTypeNil < ActiveRecord::Migration[5.2]
def change
# Add default to Resource.type
change_column :resources, :type, :string, limit: 16, default: 'Resource'
# Set default for missing Resource type
Resource.where(type: nil).update_all(type: 'Resource')
......@@ -552,7 +552,7 @@ CREATE TABLE public.resources (
meta json,
public boolean,
uuid uuid,
type character varying(16),
type character varying(16) DEFAULT 'Resource'::character varying,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
agent_id bigint,
......@@ -1519,6 +1519,7 @@ INSERT INTO "schema_migrations" (version) VALUES
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment