DEV Community

Discussion on: Create table in Rails only if it does not exist already

Collapse
 
andrewbrown profile image
Andrew Brown πŸ‡¨πŸ‡¦

You can also force a table to be dropped and then created.
A bit more destructive but works well.

create_table :repo_subscriptions, force: true do |t|
Enter fullscreen mode Exit fullscreen mode
Collapse
 
prathamesh profile image
Prathamesh Sonpatki

Yup it’s useful for tests but a bit destructive for production πŸ˜„

Collapse
 
arnabsen1729 profile image
Arnab Sen

I was actually looking for this. Thanks