diff --git a/db/migrate/20120114001001_create_monologue_users.rb b/db/migrate/20120114001001_create_monologue_users.rb index 87543337..3de47655 100644 --- a/db/migrate/20120114001001_create_monologue_users.rb +++ b/db/migrate/20120114001001_create_monologue_users.rb @@ -4,7 +4,6 @@ def change t.string :name t.string :email t.string :password_digest - t.timestamps end end diff --git a/db/migrate/20120120193858_create_monologue_posts_revisions.rb b/db/migrate/20120120193858_create_monologue_posts_revisions.rb deleted file mode 100644 index 9c027816..00000000 --- a/db/migrate/20120120193858_create_monologue_posts_revisions.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateMonologuePostsRevisions < ActiveRecord::Migration - def change - create_table :monologue_posts_revisions do |t| - t.string :title - t.text :content - t.string :url - t.integer :user_id - t.integer :post_id - t.datetime :published_at - - t.timestamps - end - - add_index :monologue_posts_revisions, :id, unique: true - add_index :monologue_posts_revisions, :published_at - add_index :monologue_posts_revisions, :post_id - end -end diff --git a/db/migrate/20120120193907_create_monologue_posts.rb b/db/migrate/20120120193907_create_monologue_posts.rb index fc1ea2d2..77af43d0 100644 --- a/db/migrate/20120120193907_create_monologue_posts.rb +++ b/db/migrate/20120120193907_create_monologue_posts.rb @@ -1,10 +1,15 @@ class CreateMonologuePosts < ActiveRecord::Migration def change create_table :monologue_posts do |t| - t.integer :posts_revision_id t.boolean :published - + t.string :title + t.text :content + t.string :url + t.integer :user_id + t.datetime :published_at t.timestamps end + + add_index :monologue_posts, :url, unique: true end end diff --git a/db/migrate/20120514194459_join_posts_and_tags.rb b/db/migrate/20120514194459_join_posts_and_tags.rb deleted file mode 100644 index 01a40cc9..00000000 --- a/db/migrate/20120514194459_join_posts_and_tags.rb +++ /dev/null @@ -1,7 +0,0 @@ -class JoinPostsAndTags < ActiveRecord::Migration - def change - create_table :posts_tags, id:false do |t| - t.integer :post_id,:tag_id - end - end -end diff --git a/db/migrate/20120526131841_migrate_old_urls.rb b/db/migrate/20120526131841_migrate_old_urls.rb deleted file mode 100644 index 3f4c385c..00000000 --- a/db/migrate/20120526131841_migrate_old_urls.rb +++ /dev/null @@ -1,22 +0,0 @@ -class MigrateOldUrls < ActiveRecord::Migration - class Monologue::PostsRevision < ActiveRecord::Base - end - - def up - mount_point = Monologue::Engine.routes.url_helpers.root_path - Monologue::PostsRevision.all.each do |r| - next if r.url.nil? - r.url = r.url.sub(mount_point, "") - r.save! - end - end - - def down - mount_point = Monologue::Engine.routes.url_helpers.root_path - Monologue::PostsRevision.all.each do |r| - next if r.url.nil? - r.url = mount_point + r.url - r.save! - end - end -end diff --git a/db/migrate/20120526195147_add_index_to_posts_revision_url.rb b/db/migrate/20120526195147_add_index_to_posts_revision_url.rb deleted file mode 100644 index 90162444..00000000 --- a/db/migrate/20120526195147_add_index_to_posts_revision_url.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToPostsRevisionUrl < ActiveRecord::Migration - def change - add_index :monologue_posts_revisions, :url - end -end diff --git a/db/migrate/20120604010152_rename_post_tags_table.rb b/db/migrate/20120604010152_rename_post_tags_table.rb deleted file mode 100644 index 7bb687ba..00000000 --- a/db/migrate/20120604010152_rename_post_tags_table.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RenamePostTagsTable < ActiveRecord::Migration - def change - rename_table :posts_tags, :monologue_posts_tags - end -end diff --git a/db/migrate/20120612015727_delete_join_posts_tags.rb b/db/migrate/20120612015727_delete_join_posts_tags.rb deleted file mode 100644 index 15fee481..00000000 --- a/db/migrate/20120612015727_delete_join_posts_tags.rb +++ /dev/null @@ -1,11 +0,0 @@ -class DeleteJoinPostsTags < ActiveRecord::Migration - def up - drop_table :monologue_posts_tags - end - - def down - create_table :monologue_posts_tags, id:false do |t| - t.integer :post_id,:tag_id - end - end -end diff --git a/db/migrate/20120612020023_add_index_to_tag_name.rb b/db/migrate/20120612020023_add_index_to_tag_name.rb deleted file mode 100644 index 72b7e921..00000000 --- a/db/migrate/20120612020023_add_index_to_tag_name.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToTagName < ActiveRecord::Migration - def change - add_index :monologue_tags, :name - end -end diff --git a/db/migrate/20130108123111_move_user_id_to_post.rb b/db/migrate/20130108123111_move_user_id_to_post.rb deleted file mode 100644 index e3800cb1..00000000 --- a/db/migrate/20130108123111_move_user_id_to_post.rb +++ /dev/null @@ -1,30 +0,0 @@ -class MoveUserIdToPost < ActiveRecord::Migration - class Monologue::PostsRevision < ActiveRecord::Base - end - - class Monologue::Post < ActiveRecord::Base - has_many :posts_revisions - end - - def up - add_column :monologue_posts, :user_id, :integer - Monologue::Post.reset_column_information - Monologue::Post.all.each do |post| - post.user_id = post.posts_revisions.first.user_id - post.save(validate: false) - end - remove_column :monologue_posts_revisions, :user_id - end - - def down - add_column :monologue_posts_revisions, :user_id, :integer - Monologue::Post.reset_column_information - Monologue::Post.all.each do |post| - post.posts_revisions.each do |revision| - revision.user_id = post.user_id - revision.save! - end - end - remove_column :monologue_posts, :user_id - end -end diff --git a/db/migrate/20130509015400_merge_revisions_into_posts.rb b/db/migrate/20130509015400_merge_revisions_into_posts.rb deleted file mode 100644 index 9d1aef27..00000000 --- a/db/migrate/20130509015400_merge_revisions_into_posts.rb +++ /dev/null @@ -1,39 +0,0 @@ -class MergeRevisionsIntoPosts < ActiveRecord::Migration - class Monologue::PostsRevision < ActiveRecord::Base - end - - class Monologue::Post < ActiveRecord::Base - end - - def up - Monologue::Post.reset_column_information - add_column :monologue_posts, :title, :string - add_column :monologue_posts, :content, :text - add_column :monologue_posts, :url, :string - add_column :monologue_posts, :published_at, :datetime - remove_column :monologue_posts, :posts_revision_id - add_index :monologue_posts, :url, unique: true - - Monologue::Post.reset_column_information - - Monologue::Post.all.each do |post| - latest_revision = latest_revision_for(post) - post.title =latest_revision.title - post.content =latest_revision.content - post.url =latest_revision.url - post.published_at =latest_revision.published_at - post.save(validate: false) - end - - drop_table :monologue_posts_revisions - end - - def down - raise ActiveRecord::IrreversibleMigration - end - - private - def latest_revision_for(post) - Monologue::PostsRevision.where("post_id = ?", post.id).order("monologue_posts_revisions.updated_at DESC").limit(1).first - end -end