refinerycms-blog icon indicating copy to clipboard operation
refinerycms-blog copied to clipboard

'refinery_settings' already exists

Open thebravoman opened this issue 7 years ago • 2 comments

I am using refinery for some time now and I've added refinerycms-blog.

Problem is the on

rake db:migrate

the following happens

StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "refinery_settings" already exists
: CREATE TABLE "refinery_settings" ("id" serial NOT NULL PRIMARY KEY, "name" character varying, "value" text, "destroyable" boolean DEFAULT 't', "scoping" character varying, "restricted" boolean DEFAULT 'f', "form_value_type" character varying, "created_at" timestamp, "updated_at" timestamp)

Should there be a check if refinery_settings already exists?

thebravoman avatar May 09 '18 06:05 thebravoman

I had to modify

    unless ActiveRecord::Base.connection.table_exists? 'refinery_settings'
      create_table :refinery_settings do |t|
        t.string    :name
        t.text      :value
        t.boolean   :destroyable,             :default => true
        t.string    :scoping
        t.boolean   :restricted,              :default => false
        t.string    :form_value_type

        t.timestamps
      end

      add_index :refinery_settings, :name
    end
# This migration comes from refinery_settings (originally 20130414130143)
class AddSlugToRefinerySettings < ActiveRecord::Migration[4.2]
  def change
  	unless ActiveRecord::Base.connection.column_exists?(:refinery_settings, :slug)
	    add_column :refinery_settings, :slug, :string, :unique => true
	  end
  end
end
# This migration comes from refinery_settings (originally 20130422105953)
class AddTitleToRefinerySettings < ActiveRecord::Migration[4.2]
  def change
  	unless ActiveRecord::Base.connection.column_exists?(:refinery_settings, :title)
    	add_column :refinery_settings, :title, :string
   	end
  end
end

Should I get this into a PR? Comments if I am missing something here?

thebravoman avatar May 09 '18 06:05 thebravoman

I don't think it's the things to do but i've seen this in refinerycms-blog: https://github.com/refinery/refinerycms-blog/blob/fcce6f6176d0e11f0ad65d7d1f477c02d6b1a4a4/lib/generators/refinery/blog/blog_generator.rb#L12

Perhaps we should add a constraint for this line.

Did you install refinerycms-settings before the blog?

bricesanchez avatar May 09 '18 12:05 bricesanchez