Class: Pasaporte::Models::CreatePasaporte

Inherits:
V
  • Object
show all
Defined in:
lib/pasaporte/models.rb

Class Method Summary collapse

Class Method Details

.downObject



73
74
75
76
77
78
79
# File 'lib/pasaporte/models.rb', line 73

def self.down
  drop_table :pasaporte_profiles
  drop_table :pasaporte_settings
  drop_table :pasaporte_associations
  drop_table :pasaporte_nonces
  drop_table :pasaporte_throttles
end

.upObject



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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pasaporte/models.rb', line 4

def self.up
  create_table :pasaporte_profiles, :force => true do |t|
    # http://openid.net/specs/openid-simple-registration-extension-1_0.html
    t.column :nickname, :string, MAX => 20
    t.column :email, :string, MAX => 70
    t.column :fullname, :string, MAX => 50
    t.column :dob, :date, :null => true
    t.column :gender, :string, MAX => 1
    t.column :postcode, :string, MAX => 10
    t.column :country, :string, MAX => 2
    t.column :language, :string, MAX => 5
    t.column :timezone, :string, MAX => 50

    # And our extensions
    # is the profile shared (visible to others)
    t.column :shared, :boolean, :default => false

    # his bio
    t.column :info, :text

    # when he last used Pasaporte
    t.column :last_login, :datetime

    # the encryption part that we generate for every user, the other is the pass
    # the total encryption key for private data will be stored in the session only when
    # the user is logged in
    t.column :secret_salt, :integer

    # Good servers delegate
    t.column :openid_server, :string
    t.column :openid_delegate, :string

    # We shard by domain
    t.column :domain_name, :string, :null => false, :default => 'localhost'

    # Keep a close watch on those who
    t.column :throttle_count, :integer, :default => 0
    t.column :suspicious, :boolean, :default => false
  end

  add_index(:pasaporte_profiles, [:nickname, :domain_name], :unique)

  create_table :pasaporte_settings do |t|
    t.column :setting, :string
    t.column :value, :binary
  end

  create_table :pasaporte_associations do |t|
    # server_url is blob, because URLs could be longer
    # than db can handle as a string
    t.column :server_url, :binary
    t.column :handle,     :string
    t.column :secret,     :binary
    t.column :issued,     :integer
    t.column :lifetime,   :integer
    t.column :assoc_type, :string
  end

  create_table :pasaporte_nonces do |t|
    t.column :nonce,   :string
    t.column :created, :integer
  end

  create_table :pasaporte_throttles do |t|
    t.column :created_at, :datetime
    t.column :client_fingerprint, :string, MAX => 40
  end
end