Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5e28e8

Browse files
committed
try067
MySQL: Support `:size` option to change text and blob sizerails/rails#35071
1 parentddb842d commitc5e28e8

File tree

8 files changed

+94
-10
lines changed

8 files changed

+94
-10
lines changed

‎app/models/user.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
classUser <ApplicationRecord
2+
end

‎config/database.yml‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,25 @@
1414
# Configure Using Gemfile
1515
# gem 'pg'
1616
#
17+
18+
# mysql2
19+
# default: &default
20+
# adapter: mysql2
21+
# encoding: utf8mb4
22+
# pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23+
# username: root
24+
# password: <%= ENV.fetch('MYSQL_ROOT_PASSWORD') %>
25+
# host: db_mysql
26+
1727
default:&default
1828
adapter:postgresql
1929
encoding:unicode
2030
# For details on connection pooling, see Rails configuration guide
2131
# https://guides.rubyonrails.org/configuring.html#database-pooling
2232
pool:<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
33+
username:<%= ENV.fetch('POSTGRES_USER') %>
34+
password:<%= ENV.fetch('POSTGRES_PASSWORD') %>
2335
host:db
24-
user:<%= ENV.fetch("POSTGRES_USER") %>
25-
password:<%= ENV.fetch("POSTGRES_PASSWORD") %>
2636

2737
development:
2838
<<:*default

‎db/migrate/20190720124709_create_user.rb‎

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
classCreateUsers <ActiveRecord::Migration[6.0]
2+
defchange
3+
create_table:usersdo |t|
4+
t.string:name
5+
t.text:profile0
6+
t.text:profile1,limit:255
7+
t.text:profile2,limit:16777215
8+
t.text:profile3# , limit: 4294967295
9+
t.text:profile4,size::tiny
10+
t.text:profile5,size::medium
11+
t.text:profile6,size::long
12+
13+
t.timestamps
14+
end
15+
end
16+
end

‎db/schema.rb‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version:2019_07_20_124709)do
13+
ActiveRecord::Schema.define(version:2019_07_26_231951)do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension"plpgsql"
1717

1818
create_table"users",force::cascadedo |t|
1919
t.string"name"
20+
t.text"profile0"
21+
t.text"profile1"
22+
t.text"profile2"
23+
t.text"profile3"
24+
t.text"profile4"
25+
t.text"profile5"
26+
t.text"profile6"
27+
t.datetime"created_at",precision:6,null:false
28+
t.datetime"updated_at",precision:6,null:false
2029
end
2130

2231
end

‎db/schema_mysql.rb‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file is auto-generated from the current state of the database. Instead
2+
# of editing this file, please use the migrations feature of Active Record to
3+
# incrementally modify your database, and then regenerate this schema definition.
4+
#
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.
10+
#
11+
# It's strongly recommended that you check this file into your version control system.
12+
13+
ActiveRecord::Schema.define(version:2019_07_26_231951)do
14+
15+
create_table"users",options:"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci",force::cascadedo |t|
16+
t.string"name"
17+
t.text"profile0"
18+
t.text"profile1",size::tiny
19+
t.text"profile2",size::medium
20+
t.text"profile3",size::long
21+
t.text"profile4",size::tiny
22+
t.text"profile5",size::medium
23+
t.text"profile6",size::long
24+
t.datetime"created_at",precision:6,null:false
25+
t.datetime"updated_at",precision:6,null:false
26+
end
27+
28+
end

‎test/fixtures/users.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2+
3+
one:
4+
name:MyString
5+
profile1:MyText
6+
profile2:MyText
7+
profile3:MyText
8+
profile4:MyText
9+
profile5:MyText
10+
profile6:MyText
11+
12+
two:
13+
name:MyString
14+
profile1:MyText
15+
profile2:MyText
16+
profile3:MyText
17+
profile4:MyText
18+
profile5:MyText
19+
profile6:MyText

‎test/models/user_test.rb‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require'test_helper'
2+
3+
classUserTest <ActiveSupport::TestCase
4+
# test "the truth" do
5+
# assert true
6+
# end
7+
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp