Class: CASServer::Models::ShortenTableNames

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

Overview

Oracle table names cannot exceed 30 chars… See code.google.com/p/rubycas-server/issues/detail?id=15

Class Method Summary collapse

Class Method Details

.downObject



204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/casserver/models.rb', line 204

def self.down
  if ActiveRecord::Base.connection.table_alias_length > 30
    rename_table :casserver_lt, :cassserver_login_tickets
    rename_table :casserver_st, :casserver_service_tickets
    rename_table :casserver_tgt, :casserver_ticket_granting_tickets
    rename_table :casserver_pgt, :casserver_proxy_granting_tickets
  else
    drop_table :casserver_pgt
    drop_table :casserver_tgt
    drop_table :casserver_st
    drop_table :casserver_lt
  end
end

.upObject



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/casserver/models.rb', line 161

def self.up
  if ActiveRecord::Base.connection.table_alias_length > 30
    $LOG.info("Shortening table names")
    rename_table :casserver_login_tickets, :casserver_lt
    rename_table :casserver_service_tickets, :casserver_st
    rename_table :casserver_ticket_granting_tickets, :casserver_tgt
    rename_table :casserver_proxy_granting_tickets, :casserver_pgt
  else
    create_table :casserver_lt, :force => true do |t|
      t.column :ticket,     :string,   :null => false
      t.column :created_on, :timestamp, :null => false
      t.column :consumed,   :datetime, :null => true
      t.column :client_hostname, :string, :null => false
    end

    create_table :casserver_st, :force => true do |t|
      t.column :ticket,     :string,    :null => false
      t.column :service,    :string,    :null => false
      t.column :created_on, :timestamp, :null => false
      t.column :consumed,   :datetime, :null => true
      t.column :client_hostname, :string, :null => false
      t.column :username,   :string,  :null => false
      t.column :type,       :string,   :null => false
      t.column :proxy_granting_ticket_id, :integer, :null => true
    end

    create_table :casserver_tgt, :force => true do |t|
      t.column :ticket,     :string,    :null => false
      t.column :created_on, :timestamp, :null => false
      t.column :client_hostname, :string, :null => false
      t.column :username,   :string,    :null => false
    end

    create_table :casserver_pgt, :force => true do |t|
      t.column :ticket,     :string,    :null => false
      t.column :created_on, :timestamp, :null => false
      t.column :client_hostname, :string, :null => false
      t.column :iou,        :string,    :null => false
      t.column :service_ticket_id, :integer, :null => false
    end
  end
end