Skip to content

Commit

Permalink
Add keyspace to drop_table
Browse files Browse the repository at this point in the history
Handles for the case where tables with the same name are in multiple keyspaces. This allows to target a specific keyspace to remove the table.
  • Loading branch information
mscoutermarsh committed Apr 10, 2024
1 parent 29efc18 commit bf3c36b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/planetscale_rails/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def create_table(table_name, **options)
end
super(table_name, **options.except(:keyspace))
end

def drop_table(table_name, **options)
if ENV["ENABLE_PSDB"] && options[:keyspace].present?
table_name = "#{options[:keyspace]}.#{table_name}"
end
super(table_name, **options.except(:keyspace))
end
end
end
end

0 comments on commit bf3c36b

Please sign in to comment.