|
| 1 | +class ReplicatePetitionModelsForArchive < ActiveRecord::Migration |
| 2 | + def change |
| 3 | + create_table :archived_debate_outcomes do |t| |
| 4 | + t.integer :petition_id, null: false |
| 5 | + t.date :debated_on |
| 6 | + t.string :transcript_url, limit: 500 |
| 7 | + t.string :video_url, limit: 500 |
| 8 | + t.text :overview |
| 9 | + t.datetime :created_at, null: false |
| 10 | + t.datetime :updated_at, null: false |
| 11 | + t.boolean :debated, default: true, null: false |
| 12 | + t.string :commons_image_file_name |
| 13 | + t.string :commons_image_content_type |
| 14 | + t.integer :commons_image_file_size |
| 15 | + t.datetime :commons_image_updated_at |
| 16 | + end |
| 17 | + |
| 18 | + add_index :archived_debate_outcomes, [:petition_id, :debated_on] |
| 19 | + add_index :archived_debate_outcomes, :petition_id, unique: true |
| 20 | + add_index :archived_debate_outcomes, :updated_at |
| 21 | + add_foreign_key :archived_debate_outcomes, :archived_petitions, column: :petition_id, on_delete: :cascade |
| 22 | + |
| 23 | + create_table :archived_government_responses do |t| |
| 24 | + t.integer :petition_id |
| 25 | + t.string :summary, limit: 500, null: false |
| 26 | + t.text :details |
| 27 | + t.datetime :created_at, null: false |
| 28 | + t.datetime :updated_at, null: false |
| 29 | + end |
| 30 | + |
| 31 | + add_index :archived_government_responses, :petition_id, unique: true |
| 32 | + add_index :archived_government_responses, :updated_at |
| 33 | + add_foreign_key :archived_government_responses, :archived_petitions, column: :petition_id, on_delete: :cascade |
| 34 | + |
| 35 | + create_table :archived_notes do |t| |
| 36 | + t.integer :petition_id |
| 37 | + t.text :details |
| 38 | + t.datetime :created_at, null: false |
| 39 | + t.datetime :updated_at, null: false |
| 40 | + end |
| 41 | + |
| 42 | + add_index :archived_notes, :petition_id, unique: true |
| 43 | + add_foreign_key :archived_notes, :archived_petitions, column: :petition_id, on_delete: :cascade |
| 44 | + |
| 45 | + create_table :archived_petition_emails, force: :cascade do |t| |
| 46 | + t.integer :petition_id |
| 47 | + t.string :subject, null: false |
| 48 | + t.text :body |
| 49 | + t.string :sent_by |
| 50 | + t.datetime :created_at, null: false |
| 51 | + t.datetime :updated_at, null: false |
| 52 | + end |
| 53 | + |
| 54 | + add_index :archived_petition_emails, :petition_id |
| 55 | + add_foreign_key :archived_petition_emails, :archived_petitions, column: :petition_id, on_delete: :cascade |
| 56 | + |
| 57 | + create_table :archived_rejections, force: :cascade do |t| |
| 58 | + t.integer :petition_id |
| 59 | + t.string :code, limit: 50, null: false |
| 60 | + t.text :details |
| 61 | + t.datetime :created_at, null: false |
| 62 | + t.datetime :updated_at, null: false |
| 63 | + end |
| 64 | + |
| 65 | + add_index :archived_rejections, :petition_id, unique: true |
| 66 | + add_foreign_key :archived_rejections, :archived_petitions, column: :petition_id, on_delete: :cascade |
| 67 | + |
| 68 | + create_table :archived_signatures do |t| |
| 69 | + t.string :name, limit: 255, null: false |
| 70 | + t.string :state, limit: 20, default: "pending", null: false |
| 71 | + t.string :perishable_token, limit: 255 |
| 72 | + t.string :postcode, limit: 255 |
| 73 | + t.string :ip_address, limit: 20 |
| 74 | + t.integer :petition_id |
| 75 | + t.datetime :created_at |
| 76 | + t.datetime :updated_at |
| 77 | + t.boolean :notify_by_email, default: true |
| 78 | + t.string :email, limit: 255 |
| 79 | + t.string :unsubscribe_token |
| 80 | + t.string :constituency_id |
| 81 | + t.datetime :validated_at |
| 82 | + t.integer :number |
| 83 | + t.boolean :seen_signed_confirmation_page, default: false, null: false |
| 84 | + t.string :location_code, limit: 30 |
| 85 | + t.datetime :invalidated_at |
| 86 | + t.integer :invalidation_id |
| 87 | + t.datetime :government_response_email_at |
| 88 | + t.datetime :debate_scheduled_email_at |
| 89 | + t.datetime :debate_outcome_email_at |
| 90 | + t.datetime :petition_email_at |
| 91 | + t.uuid :uuid |
| 92 | + t.boolean :creator, default: false, null: false |
| 93 | + t.boolean :sponsor, default: false, null: false |
| 94 | + end |
| 95 | + |
| 96 | + add_index :archived_signatures, :constituency_id |
| 97 | + add_index :archived_signatures, [:created_at, :ip_address, :petition_id], name: "index_archived_signatures_on_creation_ip_and_petition_id" |
| 98 | + add_index :archived_signatures, [:email, :petition_id, :name], unique: true |
| 99 | + add_index :archived_signatures, :invalidation_id |
| 100 | + add_index :archived_signatures, [:ip_address, :petition_id] |
| 101 | + add_index :archived_signatures, [:petition_id, :location_code] |
| 102 | + add_index :archived_signatures, :petition_id |
| 103 | + add_index :archived_signatures, [:state, :petition_id] |
| 104 | + add_index :archived_signatures, :updated_at |
| 105 | + add_index :archived_signatures, :uuid |
| 106 | + add_index :archived_signatures, :validated_at |
| 107 | + add_index :archived_signatures, [:creator, :petition_id] |
| 108 | + add_index :archived_signatures, [:sponsor, :petition_id] |
| 109 | + add_foreign_key :archived_signatures, :archived_petitions, column: :petition_id, on_delete: :cascade |
| 110 | + |
| 111 | + add_column :archived_petitions, :action, :string, limit: 255 |
| 112 | + add_column :archived_petitions, :background, :string, limit: 300 |
| 113 | + add_column :archived_petitions, :additional_details, :text |
| 114 | + add_column :archived_petitions, :government_response_at, :datetime |
| 115 | + add_column :archived_petitions, :scheduled_debate_date, :date |
| 116 | + add_column :archived_petitions, :last_signed_at, :datetime |
| 117 | + add_column :archived_petitions, :response_threshold_reached_at, :datetime |
| 118 | + add_column :archived_petitions, :debate_threshold_reached_at, :datetime |
| 119 | + add_column :archived_petitions, :rejected_at, :datetime |
| 120 | + add_column :archived_petitions, :debate_outcome_at, :datetime |
| 121 | + add_column :archived_petitions, :moderation_threshold_reached_at, :datetime |
| 122 | + add_column :archived_petitions, :debate_state, :string, limit: 30 |
| 123 | + add_column :archived_petitions, :stopped_at, :datetime |
| 124 | + add_column :archived_petitions, :special_consideration, :boolean |
| 125 | + end |
| 126 | +end |
0 commit comments