-
Open the Terminal
-
Use
mysqldumpto backup your databases -
Check for MySQL processes with:
ps -ax | grep mysql -
Stop and kill any MySQL processes
-
Analyze MySQL on HomeBrew:
brew remove mysql
heroku restartheroku pg:reset DATABASE (no need to change the DATABASE)heroku run rake db:migrateheroku run rake db:seed (if you have seed)One liner
heroku restart; heroku pg:reset DATABASE --confirm APP-NAME; heroku run rake db:migrate
| # Download rbenv | |
| if [ ! -d ~/.rbenv ]; then | |
| git clone https://github.com/sstephenson/rbenv.git ~/.rbenv | |
| fi | |
| cd ~/.rbenv | |
| git reset --hard | |
| git pull origin master | |
| desc "Truncate all tables in the database" | |
| task :truncate_all_tables! => :environment do | |
| unless Rails.env.production? | |
| puts "TRUNCATING ALL TABLES in 3 seconds!!!!" | |
| sleep 3 | |
| ActiveRecord::Base.connection.tables.each do |table| | |
| unless table == "schema_migrations" | |
| puts "Truncating #{table}." | |
| ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table} RESTART IDENTITY CASCADE;") | |
| else |
| hash = { 'foo' => 'bar' } | |
| # Version 1 | |
| hash = Hash[hash.map { |k, v| [k.to_sym, v] }] | |
| # Version 2 | |
| hash = hash.reduce({}) do |memo, (k, v)| | |
| memo.tap { |m| m[k.to_sym] = v } | |
| end |
| # 1. Clear retry set | |
| Sidekiq::RetrySet.new.clear | |
| # 2. Clear scheduled jobs | |
| Sidekiq::ScheduledSet.new.clear | |
| # 3. Clear 'Processed' and 'Failed' jobs |
| # I was using https://github.com/maclover7/trix to do: | |
| # | |
| # f.input :my_input, as: :trix_editor | |
| # | |
| # Its currently been over two weeks since Rails 5.2 was released, and the | |
| # gem was the only thing preventing me from using it in multiple projects: | |
| # https://github.com/maclover7/trix/pull/61#issuecomment-384312659 | |
| # | |
| # So I made this custom simpleform input for my apps to prevent this from happening again in the future. | |
| # |
Prerequisites:
| #!/bin/bash | |
| # Stop all containers | |
| docker stop $(docker ps -a -q) | |
| # Delete all containers | |
| docker rm $(docker ps -a -q) | |
| # Delete all images | |
| docker rmi $(docker images -q) |
É um design pattern que o Rails implementa a partir da gem ActiveRecord.
Serve para conectar a camada Model da aplicação com tabelas do database, para assim criar um modelo de domínio persistível, onde a lógica (Model) e dados (BD) são apresentados em uma única solução.
Já persiste no BD:
obj.create