Created
October 14, 2013 02:40
-
-
Save ordinaryzelig/6969876 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sequel' | |
require 'pg' | |
db_config = { | |
adapter: 'postgres', | |
host: 'localhost', | |
database: 'asdf', | |
max_connections: 10, | |
} | |
DB = Sequel.postgres(db_config) | |
# Migration | |
DB.create_table! :postgres_sequel_models do | |
primary_key :id | |
String :name, null: false, unique: true | |
Integer :idx | |
end | |
# Model | |
class PostgresSequelModel < Sequel::Model | |
end | |
PSM = PostgresSequelModel | |
10.times.map do | |
Thread.new do | |
DB.transaction(rollback: :always) do | |
PSM.new(name: 'name').save | |
sleep 1 | |
end | |
end | |
end.each(&:join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment