diff options
| author | hukl <hukl@eight.local> | 2009-02-02 00:22:54 +0100 |
|---|---|---|
| committer | hukl <hukl@eight.local> | 2009-02-02 00:22:54 +0100 |
| commit | 7a5555b1ac542e5fd5680cefaba3574677ecaa46 (patch) | |
| tree | a501453333e52b25041380cd9349898d0e0d647e /db/migrate | |
| parent | c1854b8b518bde82b80429636f73496a537c3ad5 (diff) | |
aggregation spike with flags associated to pages
Page has now a named_scope :with_flags which
accepts an array of flag names and returns
corresponding pages. Can be chained with order and
limit
Diffstat (limited to 'db/migrate')
| -rw-r--r-- | db/migrate/20090201211159_create_flags.rb | 13 | ||||
| -rw-r--r-- | db/migrate/20090201211523_add_join_table_for_flags_pages.rb | 15 |
2 files changed, 28 insertions, 0 deletions
diff --git a/db/migrate/20090201211159_create_flags.rb b/db/migrate/20090201211159_create_flags.rb new file mode 100644 index 0000000..3b9da43 --- /dev/null +++ b/db/migrate/20090201211159_create_flags.rb | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | class CreateFlags < ActiveRecord::Migration | ||
| 2 | def self.up | ||
| 3 | create_table :flags do |t| | ||
| 4 | t.string :name | ||
| 5 | |||
| 6 | t.timestamps | ||
| 7 | end | ||
| 8 | end | ||
| 9 | |||
| 10 | def self.down | ||
| 11 | drop_table :flags | ||
| 12 | end | ||
| 13 | end | ||
diff --git a/db/migrate/20090201211523_add_join_table_for_flags_pages.rb b/db/migrate/20090201211523_add_join_table_for_flags_pages.rb new file mode 100644 index 0000000..99eb9c9 --- /dev/null +++ b/db/migrate/20090201211523_add_join_table_for_flags_pages.rb | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | class AddJoinTableForFlagsPages < ActiveRecord::Migration | ||
| 2 | def self.up | ||
| 3 | create_table :flags_pages, :id => false do |t| | ||
| 4 | t.integer :flag_id | ||
| 5 | t.integer :page_id | ||
| 6 | end | ||
| 7 | add_index :flags_pages, [:flag_id] | ||
| 8 | add_index :flags_pages, [:page_id] | ||
| 9 | end | ||
| 10 | |||
| 11 | def self.down | ||
| 12 | remove_table :flags_pages | ||
| 13 | end | ||
| 14 | |||
| 15 | end | ||
