What is the best way to do this on Heroku? through the console? I do have 'dependent: :destroy' set for all the dependent tables.
Right-click the Customers table in SQL Server Object Explorer, and select Delete. In the Preview Database Updates dialog, under User Action, notice that SSDT has identified all the dependent objects, in this case, a foreign key reference that will be dropped. Click Update Database.
You may wish to delete records in one table based on values in another table. Since you can't list more than one table in the FROM clause when you are performing a delete, you can use the EXISTS clause.
Rails Delete operation using delete method Unlike the destroy method, with delete, you can remove a record directly from the database. Any dependencies to other records in the model are not taken into account. The method delete only deletes that one row in the database and nothing else.
heroku run rails console
> Model.destroy_all
The Model is the name of the model you want to destroy
You may use:
Object.delete_all
you can also set the :dependent option to :delete_all. :delete_all will issue a single SQL statement to delete all child records. because of this using :delete_all may give you better performance.
has_many :childs, :dependent => :delete_all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With