Skip to content

Instantly share code, notes, and snippets.

@andreaslillebo
andreaslillebo / id_to_uuid.rake
Created August 12, 2019 06:48 — forked from kuczmama/id_to_uuid.rake
Migrate a rails project to use uuids
# Inspired by http://www.madebyloren.com/posts/migrating-to-uuids-as-primary-keys
task id_to_uuid: :environment do
puts "[START] Convert id to uuid"
ActiveRecord::Base.connection.enable_extension 'uuid-ossp' unless ActiveRecord::Base.connection.extensions.include? 'uuid-ossp'
ActiveRecord::Base.connection.enable_extension 'pgcrypto' unless ActiveRecord::Base.connection.extensions.include? 'pgcrypto'
table_names = ActiveRecord::Base.connection.tables - ["schema_migrations", "ar_internal_metadata", "migration_validators"]
table_names.each do |table_name|
puts "[CREATE] uuid column for #{table_name}"
@andreaslillebo
andreaslillebo / test.log
Created November 19, 2017 04:44
Puma boot - Rails system specs
[72346] Puma starting in cluster mode...
[72346] * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
[72346] * Min threads: 2, max threads: 2
[72346] * Environment: test
[72346] * Process workers: 2
[72346] * Preloading application
[72346] * Listening on tcp://127.0.0.1:53429
[72346] Use Ctrl-C to stop
[72346] - Worker 0 (pid: 72402) booted, phase: 0
[72346] - Worker 1 (pid: 72403) booted, phase: 0
@andreaslillebo
andreaslillebo / ActionCable debug.png
Last active November 16, 2017 00:32
Client-side connection to ActionCable
ActionCable debug.png
@andreaslillebo
andreaslillebo / README
Created August 9, 2017 03:33 — forked from pifleo/README
Rails - models organization - Keep code structure in models consistent
# Keep code struture in models consistent
# Inspired by http://rails-bestpractices.com/posts/75-keep-code-struture-in-models-consistent
# One example: (From top to bottom)
associations
scopes
class methods
validates
callbacks
instance methods