ru.Bee 2.5.5 → 2.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df9da4aa005f2ec38a95abf69fcbfae1136b7bca3090cfee309c3cc4fb37c32d
4
- data.tar.gz: b8a5a2e187cb44e32a3cdff131cc29046d2a2fb44a876b4d76f8899188365752
3
+ metadata.gz: 5bc0864116478dee824ed56c454d381716e961ba3d08486b5dedb25eca1c423a
4
+ data.tar.gz: 94e688d7ecb3f4f9b0f06fbb89488e6a4b994320a97335c730aa9a8458757602
5
5
  SHA512:
6
- metadata.gz: ceb90376fbdd108a4948762554a266957e59b99f19a9bd2a1949ef44829f9562072335c6727a8f0d6afcca988182d42f4dfe72522fc1629c1af6622ef6cf09ab
7
- data.tar.gz: 98e3407e1113417ecf1f6d9c4db0d63f9768c79d79431c49d6eb78bb586d2411dbc59c9c72b1ddfd2c62403915d9fa546b1a2341142fd39aaa92570199d230c4
6
+ metadata.gz: 510be7a66abb2181a83aa28ccda82e4c492dc34bff1d905f926a4f98297c6be05de1320c876e1116999819c1784f8e142da29f4b816c834f1eb87e889af55902
7
+ data.tar.gz: 9c8b9b280b030a860bc42101f03e3fe8065cd22d37efa707f1a77cb9f353c95724533c4dad172eaac59e61977bb3510a3590fdaf2f206015f02c915cee248e78
data/lib/db/test.db CHANGED
Binary file
data/lib/rubee/cli/db.rb CHANGED
@@ -37,6 +37,12 @@ module Rubee
37
37
  generate_structure
38
38
  end
39
39
 
40
+ def drop_tables(_argv)
41
+ out = Rubee::SequelObject::DB.tables.each { |table| Rubee::SequelObject::DB.drop_table(table, cascade: true) }
42
+ color_puts("These tables has been dropped for #{ENV['RACK_ENV']} env", color: :cyan)
43
+ color_puts(out, color: :gray)
44
+ end
45
+
40
46
  def schema(argv)
41
47
  target_table_hash = argv[2] ? { argv[2].to_sym => STRUCTURE[argv[2].to_sym] } : nil
42
48
  (target_table_hash || STRUCTURE).each do |table_name, table_def|
@@ -250,6 +250,10 @@ module Rubee
250
250
  end
251
251
  end)
252
252
  end
253
+
254
+ def find_or_new(attrs = {})
255
+ where(attrs).first || new(**attrs)
256
+ end
253
257
  end
254
258
  end
255
259
  end
data/lib/rubee.rb CHANGED
@@ -20,7 +20,7 @@ module Rubee
20
20
  RUBEE_SUPPORT = { "Rubee::Support::Hash" => Hash, "Rubee::Support::String" => String }
21
21
  end
22
22
 
23
- VERSION = '2.5.5'
23
+ VERSION = '2.5.6'
24
24
 
25
25
  require_relative 'rubee/router'
26
26
  require_relative 'rubee/logger'
data/readme.md CHANGED
@@ -246,6 +246,26 @@ This will generate the following files
246
246
  - text, type (varchar(255))
247
247
  - user_id, type (INTEGER)
248
248
  ```
249
+ 7. You can also rpint out the schema for the table you need
250
+ ```bash
251
+ -> rubee db schema posts
252
+ --- posts
253
+ - id, (PK), type (INTEGER)
254
+ - user_id, type (INTEGER), nullable
255
+ - comment_id, type (INTEGER), nullable
256
+ - created, type (datetime), nullable
257
+ - updated, type (datetime), nullable
258
+
259
+ Foreign keys:
260
+ - comment_id → comments() on delete no_action on update no_action
261
+ - user_id → users() on delete no_action on update no_action
262
+ ```
263
+ 8. Drop all tables can be handy for development process. But be careful and make sure you pass desired environment
264
+ ```bash
265
+ RACK_ENV=test rubee db drop_tables
266
+ These tables has been dropped for test env
267
+ [:companies, :company_clients, :services]
268
+ ```
249
269
 
250
270
  [Back to content](#content)
251
271
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ru.Bee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.5
4
+ version: 2.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov