Sha256: 2cb64cfa103a7dde5b845f83af01b674d79dc94b99401a3125b5015ec5fd446f

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

<% if db.database_type == :postgres -%>
begin
  run "CREATE EXTENSION IF NOT EXISTS citext"
rescue NoMethodError # migration is being reverted
end

<% end -%>
create_table :accounts do
  primary_key :id, type: :Bignum
<% if db.database_type == :postgres -%>
  citext :email, null: false
  constraint :valid_email, email: /^[^,;@ \r\n]+@[^,@; \r\n]+\.[^,@; \r\n]+$/
<% else -%>
  String :email, null: false
<% end -%>
  String :status, null: false, default: "unverified"
<% if db.supports_partial_indexes? -%>
  index :email, unique: true, where: { status: ["unverified", "verified"] }
<% else -%>
  index :email, unique: true
<% end -%>
end

# Used if storing password hashes in a separate table (default)
create_table :account_password_hashes do
  foreign_key :id, :accounts, primary_key: true, type: :Bignum
  String :password_hash, null: false
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rodauth-rails-1.5.2 lib/generators/rodauth/migration/sequel/base.erb
rodauth-rails-1.5.1 lib/generators/rodauth/migration/sequel/base.erb