Sha256: 7af0435d6d021d812bcd724b7b17f618cbc65e85d37391c50dab03e0144724c6

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

class CreateAdminpanelTables < ActiveRecord::Migration
	def migrate(direction)
		super
		# Create a default user
		if direction == :up
			Adminpanel::User.new(:email => 'admin@admin.com', :name => "Admin", :password => 'password', :password_confirmation => 'password').save
		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

1 entries across 1 versions & 1 rubygems

Version Path
adminpanel-1.0.0 lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb