Sha256: 2acd8974dd07e81b1740b0ee02f291f0cd4092afb65482b2ca933f4f5cbee2ef
Contents?: true
Size: 1.04 KB
Versions: 35
Compression:
Stored size: 1.04 KB
Contents
= Store account status in a text column By default, Rodauth recommends using a separate table for account statuses, and linking them via foreign keys. This is useful as it achieves an enum-like behaviour, where the database ensures a constrained set of status values. However, if you use a testing environment that starts with a blank database, and don't want to fix your testing environment to support real foreign keys, you can configure Rodauth to store the account status in a text column. Doing so results in problems if a text value you do not expect gets stored in the column. We can mitigate the problems by using a CHECK constraint on the column. create_table :accounts do # ... String :status, null: false, default: "verified", check: {status: %w'unverified verified closed'} end Then we can configure Rodauth to support this. plugin :rodauth do # ... account_status_column :status account_unverified_status_value "unverified" account_open_status_value "verified" account_closed_status_value "closed" end
Version data entries
35 entries across 35 versions & 1 rubygems