aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorJames Thompson <james.b.thompson@gmail.com>2012-03-14 11:40:16 +0200
committerJames Thompson <james.b.thompson@gmail.com>2012-03-14 11:40:16 +0200
commit56d7747f54e86993415b76c92e101608e5ea44e2 (patch)
tree025b7b37f50c4c291e7e676286e7767c40adb1f9 /db
downloadrefinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.gz
refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.bz2
refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.zip
initial commit
Diffstat (limited to 'db')
-rw-r--r--db/migrate/1_create_banners_banners.rb34
-rw-r--r--db/migrate/2_create_banners_banners_pages.rb15
-rw-r--r--db/seeds.rb23
3 files changed, 72 insertions, 0 deletions
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
+