Sha256: 372a05ffbeb0c19e9267e7e0f046d4ee0fce9ce8e9f21fa0b091922bbaac40df

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

class CreateAdminpanelTables < ActiveRecord::Migration
	def migrate(direction)
		super
		# Create a default user
		if direction == :up
			if Rails.env.development?
				group = Adminpanel::Group.new(:name => "Admin")
				group.save
				Adminpanel::User.new(:email => 'admin@admin.com', :name => "Admin", :password => 'password', :password_confirmation => 'password', :group_id => group.id).save
				puts "The password for admin@admin.com is: password"

			end
		end
	end

	def change
	    create_table :adminpanel_users do |t|
	      t.string :name
	      t.string :email
	      t.string :group_id
	      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 :section_id
	      t.timestamps
	    end

	    create_table :adminpanel_groups do |t|
	      t.string :name
	      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

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-2.0.1 lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb
adminpanel-2.0.0 lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb
adminpanel-1.2.12 lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb