From 56d7747f54e86993415b76c92e101608e5ea44e2 Mon Sep 17 00:00:00 2001 From: James Thompson Date: Wed, 14 Mar 2012 11:40:16 +0200 Subject: initial commit --- db/migrate/1_create_banners_banners.rb | 34 ++++++++++++++++++++++++++++ db/migrate/2_create_banners_banners_pages.rb | 15 ++++++++++++ db/seeds.rb | 23 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 db/migrate/1_create_banners_banners.rb create mode 100644 db/migrate/2_create_banners_banners_pages.rb create mode 100644 db/seeds.rb (limited to 'db') diff --git a/db/migrate/1_create_banners_banners.rb b/db/migrate/1_create_banners_banners.rb new file mode 100644 index 0000000..680fd7b --- /dev/null +++ b/db/migrate/1_create_banners_banners.rb @@ -0,0 +1,34 @@ +class CreateBannersBanners < ActiveRecord::Migration + + def up + create_table :refinery_banners do |t| + t.string :name + t.string :title + t.string :description + t.integer :image_id + t.string :url + t.boolean :is_active + t.date :start_date + t.date :expiry_date + t.integer :position + t.integer :position + + t.timestamps + end + + end + + def down + if defined?(::Refinery::UserPlugin) + ::Refinery::UserPlugin.destroy_all({:name => "refinerycms-banners"}) + end + + if defined?(::Refinery::Page) + ::Refinery::Page.delete_all({:link_url => "/banners/banners"}) + end + + drop_table :refinery_banners + + end + +end diff --git a/db/migrate/2_create_banners_banners_pages.rb b/db/migrate/2_create_banners_banners_pages.rb new file mode 100644 index 0000000..89af8e9 --- /dev/null +++ b/db/migrate/2_create_banners_banners_pages.rb @@ -0,0 +1,15 @@ +class CreateBannersBannersPages < ActiveRecord::Migration + def self.up + create_table :refinery_banners_pages, :id => false do |t| + t.integer :page_id + t.integer :banner_id + end + + add_index :refinery_banners_pages, :page_id + add_index :refinery_banners_pages, :banner_id + end + + def self.down + drop_table :refinery_banners_pages + end +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..ccde242 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,23 @@ +if defined?(::Refinery::User) + ::Refinery::User.all.each do |user| + if user.plugins.where(:name => 'refinerycms-banners').blank? + user.plugins.create(:name => 'refinerycms-banners', + :position => (user.plugins.maximum(:position) || -1) +1) + end + end +end + + +#url = "/banners" +#if defined?(::Refinery::Page) && ::Refinery::Page.where(:link_url => url).empty? +# page = ::Refinery::Page.create( +# :title => 'Banners', +# :link_url => url, +# :deletable => false, +# :menu_match => "^#{url}(\/|\/.+?|)$" +# ) +# Refinery::Pages.default_parts.each do |default_page_part| +# page.parts.create(:title => default_page_part, :body => nil) +# end +#end + -- cgit v1.2.3