This blog is part of our Rails 6 series.
Rails 6.0 was recently released.
Rails 6 added
option to create a table if it doesn’t exist.
Before Rails 6, we could use
Default value of
users table in Rails 5.2.
Now let’s try creating
users table again with
We can see that Rails 5.2 ignored
option and tried creating the
Now let’s try
with Rails 5.2.
We can see that
create_table :users never executed because
ActiveRecord::Base.connection.table_exists?('users') returned true.
users table in Rails 6 with
option set as true.
We can see that no exception was raised when we tried creating
users table the
Now let’s see what happens if we set
As we can see, Rails raised an exception here because
was set to false.
Here is the relevant