Skip to content

Commit

Permalink
FIX: ensures migration order is correct (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Apr 9, 2020
1 parent 5665832 commit 646201d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class DropIncorrectFutureSchemaMigrations < ActiveRecord::Migration[5.2]
def up
execute <<-SQL
DELETE FROM schema_migrations WHERE version = '20201303000001';
DELETE FROM schema_migration_details WHERE version = '20201303000001';
DELETE FROM schema_migrations WHERE version = '20201303000002';
DELETE FROM schema_migration_details WHERE version = '20201303000002';
SQL
end
end
22 changes: 22 additions & 0 deletions db/migrate/20200409102640_create_post_events_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class CreatePostEventsTable < ActiveRecord::Migration[5.2]
def up
unless ActiveRecord::Base.connection.table_exists?('discourse_calendar_post_events')
create_table :discourse_calendar_post_events, id: false do |t|
t.bigint :id, null: false, primary_key: true
t.integer :status, default: 0, null: false
t.integer :display_invitees, default: 0, null: false
t.datetime :starts_at, null: false, default: -> { 'CURRENT_TIMESTAMP' }
t.datetime :ends_at
t.datetime :deleted_at
t.string :raw_invitees, array: true
t.string :name
end
end
end

def down
drop_table :discourse_calendar_post_events
end
end
21 changes: 21 additions & 0 deletions db/migrate/20200409102641_create_invitees_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

class CreateInviteesTable < ActiveRecord::Migration[5.2]
def up
unless ActiveRecord::Base.connection.table_exists?('discourse_calendar_invitees')
create_table :discourse_calendar_invitees do |t|
t.integer :post_id, null: false
t.integer :user_id, null: false
t.integer :status
t.timestamps null: false
t.boolean :notified, null: false, default: false
end

add_index :discourse_calendar_invitees, [:post_id, :user_id], unique: true
end
end

def down
drop_table :discourse_calendar_invitees
end
end
20 changes: 0 additions & 20 deletions db/migrate/20201303000001_create_post_events_table.rb

This file was deleted.

19 changes: 0 additions & 19 deletions db/migrate/20201303000002_create_invitees_table.rb

This file was deleted.

0 comments on commit 646201d

Please sign in to comment.