Sha256: 11195c7b122fbdccd3f5f6f32aa2107535dccabe0933f280a3acc7bf2d490558
Contents?: true
Size: 761 Bytes
Versions: 2
Compression:
Stored size: 761 Bytes
Contents
class CreateShortenedUrlsTable < ActiveRecord::Migration def self.up create_table :shortened_urls do |t| t.integer :user_id # we can link this to a user for interesting things t.string :url, :null => false # the real url that we will redirect to t.string :unique_key, :null => false # the unique key t.integer :use_count, :null => false, :default => 0 # how many times the link has been clicked t.timestamps end add_index :shortened_urls, :unique_key # we will lookup the links in the db with this add_index :shortened_urls, :user_id # and this end def self.down remove_index :shortened_urls, :unique_key remove_index :shortened_urls, :user_id drop_table :shortened_urls end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shortener-0.0.2 | lib/generators/shortener/templates/migration.rb |
shortener-0.0.1 | lib/generators/shortener/templates/migration.rb |