I use Rails 4.0 and Ruby 2.3.0
I have a small Rails App. At first I wanted to assign different roles to each user based what he/she had signed up for. So i tried out the "Royce" gem from https://github.com/MartinJNash/Royce
I uninstalled it after seeing that it was too complicated for my requirements.
Then I tried the "simple-roles" gem to see how it works from here https://github.com/stanislaw/simple_roles. I uninstalled tat too. I ran db:migrate when I had these 2 gems in my app.
Now I don't want the corresponding tables from these two gems in my schema.rb. Its not exactly interfering with my app, but I would like to delete them.
The following is my schema.rb file
ActiveRecord::Schema.define(version: 20160911213902) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "roles", force: :cascade do |t|
t.string "name"
t.integer "resource_id"
t.string "resource_type"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree
add_index "roles", ["name"], name: "index_roles_on_name", using: :btree
create_table "royce_connector", force: :cascade do |t|
t.integer "roleable_id", null: false
t.string "roleable_type", null: false
t.integer "role_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "royce_connector", ["role_id"], name: "index_royce_connector_on_role_id", using: :btree
add_index "royce_connector", ["roleable_id", "roleable_type"], name: "index_royce_connector_on_roleable_id_and_roleable_type", using: :btree
create_table "royce_role", force: :cascade do |t|
t.string "name", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "royce_role", ["name"], name: "index_royce_role_on_name", using: :btree
create_table "sessions", force: :cascade do |t|
t.string "session_id", null: false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", unique: true, using: :btree
add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
create_table "users", force: :cascade do |t|
t.string "email"
t.string "name"
t.string "login_token"
t.datetime "login_token_valid_until"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users_roles", id: false, force: :cascade do |t|
t.integer "user_id"
t.integer "role_id"
end
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree
create_table "vendors", force: :cascade do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "visits", force: :cascade do |t|
t.string "country"
t.datetime "visited_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
Even though i have un-installed the 2 roles-gems, everytime I run rake db:migrate, I get the above schema.
I am using only the "sessions" and "vendors" tables in my app. Any idea what I should do to get rid of these unwanted tables?
Firstly check if the table is present...in rails console...
##to view all tables
ActiveRecord::Base.connection.tables
i use rails console
to delete tables directly...
ActiveRecord::Base.connection.execute("drop table table_name")
###========OR===============
ActiveRecord::Migration.drop_table(:table_name)
###=========OR===============
ActiveRecord::Migration.drop_table("table_name")
###=========WITH EXAMPLE===============
ActiveRecord::Base.connection.drop_table :subscriptions
Then,delete the migration file or rename it again by changing timestamp and again run rake db:migrate
Hope it helps :)