arql 0.3.31 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vscode/launch.json +1 -1
- data/Gemfile.lock +1 -1
- data/README-zh_CN.org +706 -429
- data/auto-set-id-before-save-zh_CN.org +1 -1
- data/custom-configurations-zh_CN.org +40 -3
- data/define-associations-zh_CN.org +31 -17
- data/initializer-structure-zh_CN.org +22 -4
- data/lib/arql/app.rb +98 -71
- data/lib/arql/cli.rb +31 -15
- data/lib/arql/commands/info.rb +41 -28
- data/lib/arql/commands/models.rb +106 -61
- data/lib/arql/commands/reconnect.rb +8 -4
- data/lib/arql/commands/redefine.rb +3 -1
- data/lib/arql/commands/sandbox.rb +6 -4
- data/lib/arql/commands.rb +0 -2
- data/lib/arql/concerns/global_data_definition.rb +40 -6
- data/lib/arql/concerns/model_extension.rb +168 -0
- data/lib/arql/concerns/table_data_definition.rb +20 -20
- data/lib/arql/concerns.rb +1 -0
- data/lib/arql/definition.rb +169 -317
- data/lib/arql/ext/active_record/relation.rb +29 -0
- data/lib/arql/ext/active_record/result.rb +29 -0
- data/lib/arql/ext/array.rb +40 -1
- data/lib/arql/ext/kernel.rb +70 -61
- data/lib/arql/ext/object.rb +14 -0
- data/lib/arql/ext/ransack/search.rb +29 -0
- data/lib/arql/mysqldump.rb +0 -1
- data/lib/arql/ssh_proxy.rb +25 -22
- data/lib/arql/version.rb +1 -1
- data/lib/arql.rb +11 -7
- data/sql-log-zh_CN.org +8 -3
- metadata +6 -5
- data/lib/arql/commands/table.rb +0 -55
- data/lib/arql/commands/vd.rb +0 -46
- data/lib/arql/connection.rb +0 -16
@@ -91,7 +91,7 @@ module Arql
|
|
91
91
|
# Shape.add_column(:triangle, 'polygon')
|
92
92
|
# # ALTER TABLE "shapes" ADD "triangle" polygon
|
93
93
|
def add_column(column_name, type, **options)
|
94
|
-
|
94
|
+
connection.add_column(table_name, column_name, type, **options)
|
95
95
|
end
|
96
96
|
|
97
97
|
# Changes the column's definition according to the new options.
|
@@ -101,7 +101,7 @@ module Arql
|
|
101
101
|
# Post.change_column(:description, :text)
|
102
102
|
#
|
103
103
|
def change_column(column_name, type, options = {})
|
104
|
-
|
104
|
+
connection.change_column(table_name, column_name, type, **options)
|
105
105
|
end
|
106
106
|
|
107
107
|
# Removes the column from the table definition.
|
@@ -113,7 +113,7 @@ module Arql
|
|
113
113
|
# In that case, +type+ and +options+ will be used by #add_column.
|
114
114
|
# Indexes on the column are automatically removed.
|
115
115
|
def remove_column(column_name, type = nil, **options)
|
116
|
-
|
116
|
+
connection.remove_column(table_name, column_name, type, **options)
|
117
117
|
end
|
118
118
|
|
119
119
|
# Adds a new index to the table. +column_name+ can be a single Symbol, or
|
@@ -229,7 +229,7 @@ module Arql
|
|
229
229
|
#
|
230
230
|
# For more information see the {"Transactional Migrations" section}[rdoc-ref:Migration].
|
231
231
|
def add_index(column_name, options = {})
|
232
|
-
|
232
|
+
connection.add_index(table_name, column_name, **options)
|
233
233
|
end
|
234
234
|
|
235
235
|
# Adds a new foreign key.
|
@@ -277,7 +277,7 @@ module Arql
|
|
277
277
|
# [<tt>:validate</tt>]
|
278
278
|
# (PostgreSQL only) Specify whether or not the constraint should be validated. Defaults to +true+.
|
279
279
|
def add_foreign_key(to_table, **options)
|
280
|
-
|
280
|
+
connection.add_foreign_key(table_name, to_table, **options)
|
281
281
|
end
|
282
282
|
|
283
283
|
# Adds timestamps (+created_at+ and +updated_at+) columns to this table.
|
@@ -286,7 +286,7 @@ module Arql
|
|
286
286
|
# Supplier.add_timestamps(null: true)
|
287
287
|
#
|
288
288
|
def add_timestamps(**options)
|
289
|
-
|
289
|
+
connection.add_timestamps(table_name, **options)
|
290
290
|
end
|
291
291
|
|
292
292
|
# Changes the comment for a column or removes it if +nil+.
|
@@ -296,7 +296,7 @@ module Arql
|
|
296
296
|
#
|
297
297
|
# Post.change_column_comment(:state, from: "old_comment", to: "new_comment")
|
298
298
|
def change_column_comment(column_name, comment_or_changes)
|
299
|
-
|
299
|
+
connection.change_column_comment(table_name, column_name, comment_or_changes)
|
300
300
|
end
|
301
301
|
|
302
302
|
# Sets a new default value for a column:
|
@@ -314,7 +314,7 @@ module Arql
|
|
314
314
|
# Post.change_column_default(:state, from: nil, to: "draft")
|
315
315
|
#
|
316
316
|
def change_column_default(column_name, default_or_changes)
|
317
|
-
|
317
|
+
connection.change_column_default(table_name, column_name, default_or_changes)
|
318
318
|
end
|
319
319
|
|
320
320
|
# Sets or removes a <tt>NOT NULL</tt> constraint on a column. The +null+ flag
|
@@ -334,7 +334,7 @@ module Arql
|
|
334
334
|
#
|
335
335
|
# Please note the fourth argument does not set a column's default.
|
336
336
|
def change_column_null(column_name, null, default = nil)
|
337
|
-
|
337
|
+
connection.change_column_null(table_name, column_name, null, default)
|
338
338
|
end
|
339
339
|
|
340
340
|
# Renames a column.
|
@@ -342,7 +342,7 @@ module Arql
|
|
342
342
|
# Supplier.rename_column(:description, :name)
|
343
343
|
#
|
344
344
|
def rename_column(column_name, new_column_name)
|
345
|
-
|
345
|
+
connection.rename_column(table_name, column_name, new_column_name)
|
346
346
|
end
|
347
347
|
|
348
348
|
# A block for changing columns in +table+.
|
@@ -418,7 +418,7 @@ module Arql
|
|
418
418
|
#
|
419
419
|
# See also Table for details on all of the various column transformations.
|
420
420
|
def change_table(**options)
|
421
|
-
|
421
|
+
connection.change_table(table_name, **options)
|
422
422
|
end
|
423
423
|
|
424
424
|
# Renames a table.
|
@@ -426,7 +426,7 @@ module Arql
|
|
426
426
|
# rename_table('octopi')
|
427
427
|
#
|
428
428
|
def rename_table(new_name)
|
429
|
-
|
429
|
+
connection.rename_table(table_name, new_name)
|
430
430
|
end
|
431
431
|
|
432
432
|
# Changes the comment for a table or removes it if +nil+.
|
@@ -436,7 +436,7 @@ module Arql
|
|
436
436
|
#
|
437
437
|
# Post.change_table_comment(from: "old_comment", to: "new_comment")
|
438
438
|
def change_table_comment(comment_or_changes)
|
439
|
-
|
439
|
+
connection.change_table_comment(table_name, comment_or_changes)
|
440
440
|
end
|
441
441
|
|
442
442
|
# Drops a table from the database.
|
@@ -452,13 +452,13 @@ module Arql
|
|
452
452
|
# it can be helpful to provide these in a migration's +change+ method so it can be reverted.
|
453
453
|
# In that case, +options+ and the block will be used by #create_table.
|
454
454
|
def drop_table(**options)
|
455
|
-
|
455
|
+
connection.drop_table(table_name, **options)
|
456
456
|
end
|
457
457
|
|
458
458
|
# Returns an array of foreign keys for the given table.
|
459
459
|
# The foreign keys are represented as ForeignKeyDefinition objects.
|
460
460
|
def foreign_keys
|
461
|
-
|
461
|
+
connection.foreign_keys(table_name)
|
462
462
|
end
|
463
463
|
|
464
464
|
# Removes the given foreign key from the table. Any option parameters provided
|
@@ -487,7 +487,7 @@ module Arql
|
|
487
487
|
# [<tt>:to_table</tt>]
|
488
488
|
# The name of the table that contains the referenced primary key.
|
489
489
|
def remove_foreign_key(to_table = nil, **options)
|
490
|
-
|
490
|
+
connection.remove_foreign_key(table_name, to_table, **options)
|
491
491
|
end
|
492
492
|
|
493
493
|
# Removes the given index from the table.
|
@@ -518,7 +518,7 @@ module Arql
|
|
518
518
|
#
|
519
519
|
# For more information see the {"Transactional Migrations" section}[rdoc-ref:Migration].
|
520
520
|
def remove_index(options = {})
|
521
|
-
|
521
|
+
connection.remove_index(table_name, **options)
|
522
522
|
end
|
523
523
|
|
524
524
|
# Removes the timestamp columns (+created_at+ and +updated_at+) from the table definition.
|
@@ -526,7 +526,7 @@ module Arql
|
|
526
526
|
# Supplier.remove_timestamps
|
527
527
|
#
|
528
528
|
def remove_timestamps(**options)
|
529
|
-
|
529
|
+
connection.remove_timestamps(**options)
|
530
530
|
end
|
531
531
|
|
532
532
|
# Renames an index.
|
@@ -536,12 +536,12 @@ module Arql
|
|
536
536
|
# Person.rename_index 'index_people_on_last_name', 'index_users_on_last_name'
|
537
537
|
#
|
538
538
|
def rename_index(old_name, new_name)
|
539
|
-
|
539
|
+
connection.rename_index(table_name, old_name, new_name)
|
540
540
|
end
|
541
541
|
|
542
542
|
# Returns the table comment that's stored in database metadata.
|
543
543
|
def table_comment
|
544
|
-
|
544
|
+
connection.table_comment(table_name)
|
545
545
|
end
|
546
546
|
|
547
547
|
end
|
data/lib/arql/concerns.rb
CHANGED