Created
June 8, 2015 22:36
-
-
Save theunraveler/366ba9c173003d106fdc 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
| #!/usr/bin/env ruby | |
| require 'bundler/inline' | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'pg' | |
| end | |
| conn = PG.connect( dbname: 'paranoia_null_unique' ) | |
| conn.exec(' | |
| CREATE TABLE IF NOT EXISTS testing ( | |
| token varchar(32) NOT NULL, | |
| deleted_at timestamp, | |
| UNIQUE(token, deleted_at) | |
| ) | |
| ') | |
| conn.exec('DELETE FROM testing') | |
| 5.times { conn.exec("INSERT INTO testing (token) VALUES ('should_be_unique')") } | |
| conn.exec('SELECT COUNT(*) FROM testing') do |result| | |
| print "#{result.values.first.first} records!\n" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment