Sha256: a437121b9ccc9b01f2a45a72cc48e5a15435af866c14f57b46f4c7189391ab19
Contents?: true
Size: 1.62 KB
Versions: 7
Compression:
Stored size: 1.62 KB
Contents
class CreateAdminpanelTables < ActiveRecord::Migration def migrate(direction) super # Create a default user if direction == :up if Rails.env.development? Adminpanel::User.new(:email => 'admin@admin.com', :name => "Admin", :password => 'password', :password_confirmation => 'password').save puts "The password for admin@admin.com is: password" else characters = ("a".."z").to_a << ("A".."Z").to_a << (0..9).to_a <<(["!","@","#","$","%","^","&","*","(",")", "_", "-","+", "="]) password = "" 8.times do password = password + "#{characters.sample}" end puts "The password for admin@admin.com is: #{password}" Adminpanel::User.new(:email => "admin@admin.com", :name => "Admin", :password => password, :password_confirmation => password).save end end end def change create_table :adminpanel_users do |t| t.string :name t.string :email t.string :password_digest t.string :remember_token t.timestamps end add_index :adminpanel_users, [:email] add_index :adminpanel_users, [:remember_token] create_table :adminpanel_galleries do |t| t.string :file t.integer :position t.timestamps end create_table :adminpanel_images do |t| t.string :file t.integer :foreign_key t.string :model t.timestamps end create_table :adminpanel_sections do |t| t.string :name t.boolean :has_description t.text :description t.string :key t.string :page t.boolean :has_image t.timestamps end add_index :adminpanel_sections, [:key] end end
Version data entries
7 entries across 7 versions & 1 rubygems