Module: BSV::Wallet::Postgres
- Defined in:
- lib/bsv/wallet/postgres.rb,
lib/bsv/wallet/postgres/tag.rb,
lib/bsv/wallet/postgres/block.rb,
lib/bsv/wallet/postgres/input.rb,
lib/bsv/wallet/postgres/label.rb,
lib/bsv/wallet/postgres/store.rb,
lib/bsv/wallet/postgres/action.rb,
lib/bsv/wallet/postgres/basket.rb,
lib/bsv/wallet/postgres/output.rb,
lib/bsv/wallet/postgres/setting.rb,
lib/bsv/wallet/postgres/version.rb,
lib/bsv/wallet/postgres/tx_proof.rb,
lib/bsv/wallet/postgres/broadcast.rb,
lib/bsv/wallet/postgres/spendable.rb,
lib/bsv/wallet/postgres/utxo_pool.rb,
lib/bsv/wallet/postgres/output_tag.rb,
lib/bsv/wallet/postgres/arc_adapter.rb,
lib/bsv/wallet/postgres/certificate.rb,
lib/bsv/wallet/postgres/proof_store.rb,
lib/bsv/wallet/postgres/action_label.rb,
lib/bsv/wallet/postgres/display_txid.rb,
lib/bsv/wallet/postgres/output_basket.rb,
lib/bsv/wallet/postgres/output_detail.rb,
lib/bsv/wallet/postgres/broadcast_queue.rb,
lib/bsv/wallet/postgres/certificate_field.rb,
lib/bsv/wallet/postgres/broadcast_callback.rb
Overview
PostgreSQL adapter for bsv-wallet.
Call Postgres.connect before using any models. Loads the pg_enum and pg_array Sequel extensions and sets Sequel::Model.db for all models in this namespace.
Defined Under Namespace
Modules: DisplayTxid Classes: Action, ActionLabel, ArcAdapter, Basket, Block, Broadcast, BroadcastCallback, BroadcastQueue, Certificate, CertificateField, Input, Label, Output, OutputBasket, OutputDetail, OutputTag, ProofStore, Setting, Spendable, Store, Tag, TxProof, UTXOPool
Constant Summary collapse
- VERSION =
'0.100.0'
Class Attribute Summary collapse
-
.db ⇒ Sequel::Database?
readonly
The connected database.
Class Method Summary collapse
-
.connect(url_or_db) ⇒ Sequel::Database
Establish a database connection for all models.
-
.disconnect ⇒ Object
Disconnect and clear the database reference.
-
.migrate!(target: nil) ⇒ Object
Run pending migrations against the connected database.
Class Attribute Details
.db ⇒ Sequel::Database? (readonly)
Returns the connected database.
45 46 47 |
# File 'lib/bsv/wallet/postgres.rb', line 45 def db @db end |
Class Method Details
.connect(url_or_db) ⇒ Sequel::Database
Establish a database connection for all models.
51 52 53 54 55 56 57 58 |
# File 'lib/bsv/wallet/postgres.rb', line 51 def connect(url_or_db) @db = url_or_db.is_a?(Sequel::Database) ? url_or_db : Sequel.connect(url_or_db) @db.extension :pg_enum @db.extension :pg_array @db.extension :pg_json Sequel::Model.db = @db @db end |
.disconnect ⇒ Object
Disconnect and clear the database reference.
61 62 63 64 |
# File 'lib/bsv/wallet/postgres.rb', line 61 def disconnect @db&.disconnect @db = nil end |
.migrate!(target: nil) ⇒ Object
Run pending migrations against the connected database.
69 70 71 72 73 |
# File 'lib/bsv/wallet/postgres.rb', line 69 def migrate!(target: nil) Sequel.extension :migration migrations_path = File.('../../db/migrations', __dir__) Sequel::Migrator.run(@db, migrations_path, target: target) end |