2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/generators/shortener/templates/migration.rb', line 2
def change
create_table :shortened_urls do |t|
t.integer :owner_id
t.string :owner_type, limit: 20
t.text :url, null: false, length: 2083
t.string :unique_key, limit: 10, null: false
t.string :category
t.integer :use_count, null: false, default: 0
t.datetime :expires_at
t.timestamps
end
add_index :shortened_urls, :unique_key, unique: true
add_index :shortened_urls, :url, length: 2083
add_index :shortened_urls, [:owner_id, :owner_type]
add_index :shortened_urls, :category
end
|