Skip to content

Commit e14b316

Browse files
committed
#3d899pe - Update Nullability of columns in MySQL
1 parent 3ae6295 commit e14b316

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class UpdateNullConstraintsOnTablesCols < ActiveRecord::Migration[7.0]
2+
def change
3+
change_column_null :applications, :name, false
4+
change_column_null :applications, :token, false
5+
change_column_null :applications, :chats_count, false
6+
7+
change_column_null :chats, :name, false
8+
change_column_null :chats, :number, false
9+
change_column_null :chats, :messages_count, false
10+
11+
change_column_null :messages, :body, false
12+
change_column_null :messages, :number, false
13+
end
14+
end

db/schema.rb

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

13-
ActiveRecord::Schema[7.0].define(version: 2022_09_03_052104) do
13+
ActiveRecord::Schema[7.0].define(version: 2022_09_03_052718) do
1414
create_table "applications", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
15-
t.string "name"
16-
t.string "token"
15+
t.string "name", null: false
16+
t.string "token", null: false
1717
t.datetime "created_at", null: false
1818
t.datetime "updated_at", null: false
19-
t.integer "chats_count", default: 0
19+
t.integer "chats_count", default: 0, null: false
2020
t.index ["token"], name: "index_applications_on_token", unique: true
2121
end
2222

2323
create_table "chats", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
24-
t.string "name"
25-
t.integer "number"
26-
t.integer "messages_count", default: 0
24+
t.string "name", null: false
25+
t.integer "number", null: false
26+
t.integer "messages_count", default: 0, null: false
2727
t.bigint "application_id", null: false
2828
t.datetime "created_at", null: false
2929
t.datetime "updated_at", null: false
@@ -32,8 +32,8 @@
3232
end
3333

3434
create_table "messages", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
35-
t.string "body"
36-
t.integer "number"
35+
t.string "body", null: false
36+
t.integer "number", null: false
3737
t.bigint "chat_id", null: false
3838
t.datetime "created_at", null: false
3939
t.datetime "updated_at", null: false

0 commit comments

Comments
 (0)