8000 rails activestorage:install && rails db:migrate · venkata-qa/demo.activeadmin.info@6b25d2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b25d2f

Browse files
rails activestorage:install && rails db:migrate
1 parent e5574a9 commit 6b25d2f

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This migration comes from active_storage (originally 20170806125915)
2+
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3+
def change
4+
create_table :active_storage_blobs do |t|
5+
t.string :key, null: false
6+
t.string :filename, null: false
7+
t.string :content_type
8+
t.text :metadata
9+
t.bigint :byte_size, null: false
10+
t.string :checksum, null: false
11+
t.datetime :created_at, null: false
12+
13+
t.index [ :key ], unique: true
14+
end
15+
16+
create_table :active_storage_attachments do |t|
17+
t.string :name, null: false
18+
t.references :record, null: false, polymorphic: true, index: false
19+
t.references :blob, null: false
20+
21+
t.datetime :created_at, null: false
22+
23+
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
24+
t.foreign_key :active_storage_blobs, column: :blob_id
25+
end
26+
end
27+
end

db/schema.rb

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# of editing this file, please use the migrations feature of Active Record to
33
# incrementally modify your database, and then regenerate this schema definition.
44
#
5-
# Note that this schema.rb definition is the authoritative source for your
6-
# database schema. If you need to create the application database on another
7-
# system, you should be using db:schema:load, not running all the migrations
8-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
9-
# you'll amass, the slower it'll run and the greater likelihood for issues).
5+
# This file is the source Rails uses to define your schema when running `rails
6+
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
7+
# be faster and is potentially less error prone than running all of your
8+
# migrations from scratch. Old migrations may fail to apply correctly if those
9+
# migrations use external dependencies or application code.
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2012_02_22_083938) do
13+
ActiveRecord::Schema.define(version: 2021_02_04_190042) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -29,6 +29,27 @@
2929
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
3030
end
3131

32+
create_table "active_storage_attachments", force: :cascade do |t|
33+
t.string "name", null: false
34+
t.string "record_type", null: false
35+
t.bigint "record_id", null: false
36+
t.bigint "blob_id", null: false
37+
t.datetime "created_at", null: false
38+
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
39+
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
40+
end
41+
42+
create_table "active_storage_blobs", force: :cascade do |t|
43+
t.string "key", null: false
44+
t.string "filename", null: false
45+
t.string "content_type"
46+
t.text "metadata"
47+
t.bigint "byte_size", null: false
48+
t.string "checksum", null: false
49+
t.datetime "created_at", null: false
50+
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
51+
end
52+
3253
create_table "admin_users", force: :cascade do |t|
3354
t.string "email", default: "", null: false
3455
t.string "encrypted_password", default: "", null: false
@@ -103,4 +124,5 @@
103124
t.datetime "updated_at", null: false
104125
end
105126

127+
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
106128
end

0 commit comments

Comments
 (0)
0