roda-gen 1.0.0
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 +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/bin/roda +11 -0
- data/lib/roda-gen.rb +3 -0
- data/lib/roda_gen/app_name.rb +29 -0
- data/lib/roda_gen/cli.rb +122 -0
- data/lib/roda_gen/generators/daemon.rb +78 -0
- data/lib/roda_gen/generators/migration.rb +68 -0
- data/lib/roda_gen/generators/migration_numbering.rb +21 -0
- data/lib/roda_gen/generators/model.rb +75 -0
- data/lib/roda_gen/generators/project.rb +145 -0
- data/lib/roda_gen/generators/route.rb +71 -0
- data/lib/roda_gen/generators/templates/daemon/bin/%daemon_name%.tt +13 -0
- data/lib/roda_gen/generators/templates/daemon/lib/daemon/%daemon_name%.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/daemon/spec/daemons/%daemon_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/migration/db/migrate/%migration_filename%.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/model/db/migrate/%migration_filename%.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/model/models/%resource_name%.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/model/spec/models/%resource_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/%app_name%.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/.bundle/config.tt +3 -0
- data/lib/roda_gen/generators/templates/project/.erb_lint.yml.tt +29 -0
- data/lib/roda_gen/generators/templates/project/.gitignore.tt +19 -0
- data/lib/roda_gen/generators/templates/project/.reek.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/.rspec.tt +4 -0
- data/lib/roda_gen/generators/templates/project/.rubocop.yml.tt +119 -0
- data/lib/roda_gen/generators/templates/project/.ruby-version.tt +1 -0
- data/lib/roda_gen/generators/templates/project/.rubycritic.yml.tt +15 -0
- data/lib/roda_gen/generators/templates/project/Gemfile.tt +109 -0
- data/lib/roda_gen/generators/templates/project/Procfile.dev.tt +7 -0
- data/lib/roda_gen/generators/templates/project/README.md.tt +891 -0
- data/lib/roda_gen/generators/templates/project/Rakefile.tt +3 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/admin.js.tt +84 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/app.js.tt +29 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/push.js.tt +53 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/upload.js.tt +200 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/app.css.tt +52 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/typography.css.tt +85 -0
- data/lib/roda_gen/generators/templates/project/bin/console.tt +2 -0
- data/lib/roda_gen/generators/templates/project/bin/dev.tt +8 -0
- data/lib/roda_gen/generators/templates/project/bin/gdpr_worker.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/push_sender.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/setup.tt +224 -0
- data/lib/roda_gen/generators/templates/project/bin/shrine_clean_cache.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/boot.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/config/console.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/database.rb.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/00_environments.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/01_logger.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/02_app_config.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/10_database.rb.tt +3 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/15_mail.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/20_redis.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/25_rack_attack.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/30_i18n.rb.tt +37 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/35_listen_job.rb.tt +4 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/37_shrine.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/40_routing.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/41_render.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/43_static.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/44_sessions.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/45_security.rb.tt +49 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/46_flash.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/47_json.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/48_errors.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/49_misc.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/50_mailer.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/51_locale_kit.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/52_consent_kit.rb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/55_audit_log.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/56_form_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/57_rodauth.rb.tt +304 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/60_web_push.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/61_flipper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/62_split.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/puma.rb.tt +24 -0
- data/lib/roda_gen/generators/templates/project/config/settings/development.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings/production.yml.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/settings/test.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config.ru.tt +36 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_account_profiles.rb.tt +66 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_accounts.rb.tt +70 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_audit_log.rb.tt +185 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_authorization.rb.tt +68 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_countries.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_calling_codes.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_exit_codes.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_languages.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_time_zones.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_currencies.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_gdpr_requests.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_languages.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_push_subscriptions.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_rodauth_features.rb.tt +105 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_settings.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_countries.csv.tt +250 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_currencies.csv.tt +162 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_languages.csv.tt +144 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_calling_codes.csv.tt +237 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_exit_codes.csv.tt +239 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_languages.csv.tt +226 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_time_zones.csv.tt +369 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/03_setting_system_defaults.yml.tt +35 -0
- data/lib/roda_gen/generators/templates/project/db/seeds.rb.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/Caddyfile.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/logrotate/%app_name%-caddy.tt +11 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-gdpr-worker.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-push-sender.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%.service.tt +36 -0
- data/lib/roda_gen/generators/templates/project/helpers/audit_helper.rb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/helpers/authorization_helper.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/helpers/current_account_helper.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/helpers/feature_flag_helper.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/helpers/form_helper.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/helpers/http_cache_helper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/helpers/logger_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/helpers/split_helper.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_context.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_lookup.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/base.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/gdpr_worker.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/push_sender.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/shrine_cache_cleaner.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/deploy_check.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/lib/filtered_logger.rb.tt +54 -0
- data/lib/roda_gen/generators/templates/project/lib/gdpr.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/lib/rbac_audit.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/.rubocop.yml.tt +4 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/audit.rake.tt +85 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/console.rake.tt +8 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/db.rake.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/deploy.rake.tt +38 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/flags.rake.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/gdpr.rake.tt +31 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/parser_current_shim.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/quality.rake.tt +84 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/secrets.rake.tt +154 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/spec.rake.tt +136 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/split.rake.tt +27 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/tailwind.rake.tt +35 -0
- data/lib/roda_gen/generators/templates/project/locales/de.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/en.yml.tt +321 -0
- data/lib/roda_gen/generators/templates/project/locales/es.yml.tt +326 -0
- data/lib/roda_gen/generators/templates/project/locales/fr.yml.tt +329 -0
- data/lib/roda_gen/generators/templates/project/locales/it.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/de.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/en.yml.tt +6 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/es.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/fr.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/it.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/sv.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/tru.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/sv.yml.tt +319 -0
- data/lib/roda_gen/generators/templates/project/locales/tru.yml.tt +294 -0
- data/lib/roda_gen/generators/templates/project/log/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/models/account.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/models/account_privilege.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/models/account_profile.rb.tt +115 -0
- data/lib/roda_gen/generators/templates/project/models/account_role.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/audit_action.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/models/audit_actor_type.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/audit_log.rb.tt +257 -0
- data/lib/roda_gen/generators/templates/project/models/audit_status.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/models/country.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/models/country_calling_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_exit_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_language.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/models/country_time_zone.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/currency.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/gdpr_request.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/models/gender.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/language.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/models/privilege.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/push_subscription.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/role.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/role_privilege.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/setting_system_default.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/models/setting_user_value.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/models/settings.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/models/signup_form_data.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/models.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/package.json.tt +13 -0
- data/lib/roda_gen/generators/templates/project/public/apple-touch-icon.png +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.ico +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.svg.tt +5 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Italic-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-BoldItalic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Italic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NOTICE.md +17 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/manifest.webmanifest.tt +12 -0
- data/lib/roda_gen/generators/templates/project/public/robots.txt.tt +4 -0
- data/lib/roda_gen/generators/templates/project/public/service-worker.js.tt +27 -0
- data/lib/roda_gen/generators/templates/project/routes/account.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/routes/admin.rb.tt +118 -0
- data/lib/roda_gen/generators/templates/project/routes/gdpr.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/routes/heartbeat.rb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/routes/legal.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/routes/profile.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/project/routes/push.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/role_boundary_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/spec_helper.rb.tt +146 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/support/auth_helpers.rb.tt +71 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/auth_spec.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/consent_nojs_spec.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/create_account_form_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/otp_lifecycle_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/profile_form_spec.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/upload_spec.rb.tt +102 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/auth_pages_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/legal_pages_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/base_spec.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/gdpr_worker_spec.rb.tt +72 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/push_sender_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/locale_parity_spec.rb.tt +58 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_profile_spec.rb.tt +180 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_spec.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_actor_type_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_log_spec.rb.tt +398 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_status_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/authorization_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_calling_code_spec.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_exit_code_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_language_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_spec.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_time_zone_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/currency_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/deploy_check_spec.rb.tt +143 -0
- data/lib/roda_gen/generators/templates/project/spec/models/gdpr_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/language_spec.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/spec/models/rbac_audit_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_system_default_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_user_value_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/models/settings_spec.rb.tt +63 -0
- data/lib/roda_gen/generators/templates/project/spec/models/signup_form_data_spec.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/spec/spec_helper.rb.tt +93 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_log_helpers.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_lookup_shared_examples.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/spec/support/auth_helpers.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/support/faker.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/spec/web/admin_spec.rb.tt +155 -0
- data/lib/roda_gen/generators/templates/project/spec/web/audit_log_spec.rb.tt +159 -0
- data/lib/roda_gen/generators/templates/project/spec/web/auth_spec.rb.tt +492 -0
- data/lib/roda_gen/generators/templates/project/spec/web/authorization_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/web/boot_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/consent_banner_spec.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/spec/web/feature_flag_helper_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/web/flags_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/web/gdpr_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/heartbeat_spec.rb.tt +65 -0
- data/lib/roda_gen/generators/templates/project/spec/web/host_allowlist_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/legal_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/web/locale_resolver_spec.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_helper_spec.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/web/otp_audit_spec.rb.tt +147 -0
- data/lib/roda_gen/generators/templates/project/spec/web/profile_spec.rb.tt +97 -0
- data/lib/roda_gen/generators/templates/project/spec/web/push_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_runtime_spec.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_spec.rb.tt +81 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rbac_audit_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/request_id_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/role_boundary_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/web/session_skip_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/web/split_helper_spec.rb.tt +38 -0
- data/lib/roda_gen/generators/templates/project/spec/web/type_routing_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/upload_zone_spec.rb.tt +91 -0
- data/lib/roda_gen/generators/templates/project/tmp/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/vendor/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/views/403.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/404.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/500.erb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/views/_head_meta.erb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/views/_impersonate_picker.erb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/views/_language_switcher.erb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/views/_locked_accounts.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/_upload_zone.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/account/profile.erb.tt +149 -0
- data/lib/roda_gen/generators/templates/project/views/admin/flags.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_banner.erb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_preferences.erb.tt +87 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/erased.erb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/index.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/layout.erb.tt +112 -0
- data/lib/roda_gen/generators/templates/project/views/legal/contact.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/legal/cookies.erb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/views/legal/disclaimer.erb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/views/legal/privacy.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/account_unlocked.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_erased.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_export.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/add-recovery-codes.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-login.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-password.erb.tt +41 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/close-account.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/confirm-password.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/create-account.erb.tt +183 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/login.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/logout.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-auth.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-disable.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-setup.erb.tt +48 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock-not-available.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-auth.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-codes.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/remember.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password-request.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-auth.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-disable.erb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-manage.erb.tt +36 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account-request.erb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account-resend.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account.erb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-login-change.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/route/routes/%plural%.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/route/spec/web/%plural%_spec.rb.tt +36 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/index.erb.tt +11 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/show.erb.tt +7 -0
- data/lib/roda_gen/generators/templates/upload/db/migrate/%migration_filename%.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/upload/helpers/upload_serving.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%_uploader.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/upload/routes/%plural%.rb.tt +44 -0
- data/lib/roda_gen/generators/templates/upload/spec/web/%plural%_spec.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/upload/views/%plural%/index.erb.tt +18 -0
- data/lib/roda_gen/generators/upload.rb +83 -0
- data/lib/roda_gen/project_context.rb +30 -0
- data/lib/roda_gen/version.rb +5 -0
- data/lib/roda_gen.rb +16 -0
- metadata +497 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'flipper'
|
|
4
|
+
require 'flipper/adapters/redis'
|
|
5
|
+
require_relative '../../helpers/feature_flag_helper'
|
|
6
|
+
|
|
7
|
+
# Flipper's Redis adapter holds a single client, the ConnectionPool::Wrapper checks a
|
|
8
|
+
# connection out of REDIS per call so reads on request threads stay thread-safe
|
|
9
|
+
Flipper.configure do |config|
|
|
10
|
+
config.adapter { Flipper::Adapters::Redis.new(ConnectionPool::Wrapper.new(pool: REDIS)) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class <%= @app.camel %>
|
|
14
|
+
plugin FeatureFlagHelper
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'split'
|
|
4
|
+
require_relative '../../helpers/split_helper'
|
|
5
|
+
|
|
6
|
+
# SessionAdapter is Split's default, set explicitly so variants stay in the Rack session
|
|
7
|
+
# (a necessary cookie) and no experiment sets an extra cookie
|
|
8
|
+
Split.configure do |config|
|
|
9
|
+
config.redis = ConnectionPool::Wrapper.new(pool: REDIS)
|
|
10
|
+
config.persistence = Split::Persistence::SessionAdapter
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class <%= @app.camel %>
|
|
14
|
+
plugin SplitHelper
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Capybara's in-process Puma uses Rack::Handler::Puma and does NOT read this file
|
|
4
|
+
|
|
5
|
+
threads_count = ENV.fetch('PUMA_THREADS', 5).to_i
|
|
6
|
+
threads threads_count, threads_count
|
|
7
|
+
|
|
8
|
+
environment ENV.fetch('RACK_ENV', 'development')
|
|
9
|
+
|
|
10
|
+
if ENV.fetch('RACK_ENV', 'development') == 'production'
|
|
11
|
+
# umask=0117 gives mode 0660, pair with Group=caddy in the systemd unit so Caddy
|
|
12
|
+
# can read it. Path must match deploy/Caddyfile
|
|
13
|
+
bind "unix://#{File.expand_path('../tmp/puma.sock', __dir__)}?umask=0117"
|
|
14
|
+
|
|
15
|
+
workers ENV.fetch('PUMA_WORKERS', 2).to_i
|
|
16
|
+
|
|
17
|
+
# Puma turns preload_app on once workers > 1, booting Sequel's libpq socket in the
|
|
18
|
+
# master before forking. Sequel is not fork-aware, so the shared fd corrupts and pg segfaults
|
|
19
|
+
preload_app! false
|
|
20
|
+
else
|
|
21
|
+
port ENV.fetch('PORT', 9292)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
plugin :tmp_restart
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Merged on top of settings.yml, secrets in settings/development.local.yml
|
|
2
|
+
site:
|
|
3
|
+
domain:
|
|
4
|
+
scheme: "http"
|
|
5
|
+
host: "localhost"
|
|
6
|
+
|
|
7
|
+
# Homebrew's macOS socket, db 0 (test uses db 1 on the same instance)
|
|
8
|
+
redis:
|
|
9
|
+
url: "unix:///opt/homebrew/var/run/redis.sock?db=0"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Merged on top of settings.yml, secrets in settings/production.local.yml
|
|
2
|
+
# (mode 0600, never committed, rake secrets:print emits a template)
|
|
3
|
+
site:
|
|
4
|
+
domain:
|
|
5
|
+
scheme: "https"
|
|
6
|
+
host: "<%= @app.dash %>.example.com" # replace with the real domain
|
|
7
|
+
# Extra Host: headers accepted beyond domain.host, backstops Rodauth's reset-link
|
|
8
|
+
# generation against a hostile Host header (HostAllowlist in 45_security.rb, production only)
|
|
9
|
+
allowed_hosts: []
|
|
10
|
+
|
|
11
|
+
# Debian socket, RHEL uses /var/run/redis/redis.sock
|
|
12
|
+
redis:
|
|
13
|
+
url: "unix:///var/run/redis/redis-server.sock?db=0"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Committed, non-secret, identical across environments. Per-env values in
|
|
2
|
+
# settings/<env>.yml, secrets in the gitignored settings/<env>.local.yml (rake secrets:install).
|
|
3
|
+
# [...] placeholders are legally required (E-handelslag 2 § 7, EU 2000/31/EC Art. 5,
|
|
4
|
+
# GDPR Art. 13) and break the legal pages until filled
|
|
5
|
+
site:
|
|
6
|
+
company:
|
|
7
|
+
name: "<%= @app.human %>"
|
|
8
|
+
org_nr: "[ORG NR]" # Swedish organisationsnummer NNNNNN-NNNN
|
|
9
|
+
vat_id: "[VAT ID]" # SE + org nr + 01, for instance SE5567773456 01
|
|
10
|
+
representative: "[FULL NAME]" # Verkställande direktör / signatory
|
|
11
|
+
|
|
12
|
+
address:
|
|
13
|
+
street: "[STREET]"
|
|
14
|
+
postal_code: "[POSTAL CODE]"
|
|
15
|
+
city: "[CITY]"
|
|
16
|
+
country: "Sweden"
|
|
17
|
+
country_code: "SE"
|
|
18
|
+
|
|
19
|
+
contact:
|
|
20
|
+
email: "[EMAIL]"
|
|
21
|
+
phone: "[PHONE]"
|
|
22
|
+
data_protection: "[EMAIL]" # GDPR Art. 13 contact for data-subject requests
|
|
23
|
+
|
|
24
|
+
regulator:
|
|
25
|
+
supervisory_body: "Integritetsskyddsmyndigheten (IMY)"
|
|
26
|
+
governing_law: "Swedish law"
|
|
27
|
+
|
|
28
|
+
# Bump on a material policy change, invalidates all recorded consent
|
|
29
|
+
consent:
|
|
30
|
+
policy_version: 1
|
|
31
|
+
|
|
32
|
+
# SMTP credentials go in settings/<env>.local.yml
|
|
33
|
+
mail:
|
|
34
|
+
accounts:
|
|
35
|
+
default:
|
|
36
|
+
from: "no-reply@<%= @app.dash %>.example.com"
|
|
37
|
+
|
|
38
|
+
# subject is the VAPID sub claim, a mailto: or https: URL push services use to
|
|
39
|
+
# reach you. Keypair goes in settings/<env>.local.yml
|
|
40
|
+
web_push:
|
|
41
|
+
subject: "mailto:no-reply@<%= @app.dash %>.example.com"
|
|
42
|
+
|
|
43
|
+
# Must match a locales/*.yml file, de without locales/de.yml crashes boot
|
|
44
|
+
i18n:
|
|
45
|
+
default_locale: en
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'config/boot'
|
|
4
|
+
require_relative 'config/database'
|
|
5
|
+
|
|
6
|
+
if ENV.fetch('RACK_ENV', 'development') == 'development'
|
|
7
|
+
# After config/database so it patches Sequel
|
|
8
|
+
require 'rack-mini-profiler'
|
|
9
|
+
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::MemoryStore
|
|
10
|
+
use Rack::MiniProfiler
|
|
11
|
+
|
|
12
|
+
require 'rack/unreloader'
|
|
13
|
+
Unreloader = Rack::Unreloader.new(subclasses: %w[Sequel::Model Roda]) { <%= @app.camel %> }
|
|
14
|
+
Sequel::Model.cache_associations = false
|
|
15
|
+
|
|
16
|
+
# App MUST load before models, Account mixes in Rodauth::Model(<%= @app.camel %>.rodauth)
|
|
17
|
+
# and needs the rodauth plugin configured first
|
|
18
|
+
Unreloader.require './<%= @app.snake %>.rb'
|
|
19
|
+
Unreloader.require './models/*.rb'
|
|
20
|
+
Unreloader.require './helpers/*.rb'
|
|
21
|
+
Unreloader.require './routes/*.rb'
|
|
22
|
+
# SQL with timings to the dev console: the application-level signal a
|
|
23
|
+
# dev loop reads. Attached here and in config/console.rb, not in the
|
|
24
|
+
# database initializer, so rake tasks (setup, migrations, seeds) keep
|
|
25
|
+
# their own clean narration.
|
|
26
|
+
<%= @app.camel %>.logger.then do |logger|
|
|
27
|
+
DB.sql_log_level = :debug
|
|
28
|
+
DB.loggers << logger
|
|
29
|
+
end
|
|
30
|
+
<%= @app.camel %>.logger.info("<%= @app.camel %> web booted env=development ruby=#{RUBY_VERSION} pid=#{Process.pid}")
|
|
31
|
+
run Unreloader
|
|
32
|
+
else
|
|
33
|
+
require_relative '<%= @app.snake %>'
|
|
34
|
+
<%= @app.camel %>.logger.info("<%= @app.camel %> web booted env=#{ENV.fetch('RACK_ENV', nil)} ruby=#{RUBY_VERSION} pid=#{Process.pid}")
|
|
35
|
+
run <%= @app.camel %>.freeze.app
|
|
36
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# 1:1 with accounts, filled by Rodauth's after_create_account hook.
|
|
4
|
+
# FKs into the ISO reference tables, run rake db:seed before signing up real users
|
|
5
|
+
Sequel.migration do
|
|
6
|
+
up do
|
|
7
|
+
create_table(:genders) do
|
|
8
|
+
String :gender, primary_key: true
|
|
9
|
+
String :description
|
|
10
|
+
end
|
|
11
|
+
self[:genders].multi_insert([
|
|
12
|
+
{ gender: 'male', description: 'Male' },
|
|
13
|
+
{ gender: 'female', description: 'Female' },
|
|
14
|
+
{ gender: 'non_binary', description: 'Non-binary' }
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
create_table(:account_profiles) do
|
|
18
|
+
foreign_key :account_id, :accounts, primary_key: true, type: :Bignum
|
|
19
|
+
|
|
20
|
+
String :first_name, null: false
|
|
21
|
+
String :last_name, null: false
|
|
22
|
+
String :address, null: false
|
|
23
|
+
String :postal_code, null: false
|
|
24
|
+
String :city, null: false
|
|
25
|
+
|
|
26
|
+
foreign_key :country, :countries, type: String, null: false
|
|
27
|
+
foreign_key :language, :languages, type: String, null: false
|
|
28
|
+
foreign_key :time_zone, :country_time_zones, type: String, null: false
|
|
29
|
+
|
|
30
|
+
String :mobile_number, null: false
|
|
31
|
+
# Swedish personnummer, canonical 12 digits (YYYYMMDDNNNC). CHECK is shape-only,
|
|
32
|
+
# the model adds date validity + Luhn on top
|
|
33
|
+
String :personal_identity_number, size: 12, fixed: true, null: false, unique: true
|
|
34
|
+
constraint(:account_profiles_personal_identity_number_chk,
|
|
35
|
+
Sequel.lit("personal_identity_number ~ '^[0-9]{12}$'"))
|
|
36
|
+
foreign_key :gender, :genders, type: String # NULL = prefer not to say
|
|
37
|
+
|
|
38
|
+
column :created_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
|
|
39
|
+
column :last_modified, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
run <<~SQL
|
|
43
|
+
CREATE OR REPLACE FUNCTION set_account_profiles_last_modified()
|
|
44
|
+
RETURNS trigger
|
|
45
|
+
LANGUAGE plpgsql
|
|
46
|
+
AS $$
|
|
47
|
+
BEGIN
|
|
48
|
+
NEW.last_modified := CURRENT_TIMESTAMP;
|
|
49
|
+
RETURN NEW;
|
|
50
|
+
END;
|
|
51
|
+
$$;
|
|
52
|
+
|
|
53
|
+
CREATE TRIGGER set_account_profiles_last_modified
|
|
54
|
+
BEFORE UPDATE ON account_profiles
|
|
55
|
+
FOR EACH ROW
|
|
56
|
+
EXECUTE PROCEDURE set_account_profiles_last_modified();
|
|
57
|
+
SQL
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
down do
|
|
61
|
+
run 'DROP TRIGGER IF EXISTS set_account_profiles_last_modified ON account_profiles'
|
|
62
|
+
run 'DROP FUNCTION IF EXISTS set_account_profiles_last_modified()'
|
|
63
|
+
drop_table :account_profiles
|
|
64
|
+
drop_table :genders
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
# Password hashes live in rodauth_secrets. The web role gets EXECUTE on the two
|
|
6
|
+
# SECURITY DEFINER functions but no SELECT on the hash table, so a SQL injection can't dump hashes
|
|
7
|
+
Sequel.migration do
|
|
8
|
+
up do
|
|
9
|
+
create_table(:account_statuses) do
|
|
10
|
+
Integer :id, primary_key: true
|
|
11
|
+
String :name, null: false, unique: true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
self[:account_statuses].multi_insert([
|
|
15
|
+
{ id: 1, name: 'Unverified' },
|
|
16
|
+
{ id: 2, name: 'Verified' },
|
|
17
|
+
{ id: 3, name: 'Closed' }
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
run 'CREATE EXTENSION IF NOT EXISTS citext'
|
|
21
|
+
|
|
22
|
+
create_table(:accounts) do
|
|
23
|
+
primary_key :id, type: :Bignum
|
|
24
|
+
foreign_key :status_id, :account_statuses, null: false, default: 1
|
|
25
|
+
column :email, :citext, null: false
|
|
26
|
+
index Sequel.function(:lower, :email), unique: true, name: :accounts_email_lower_idx
|
|
27
|
+
constraint(:accounts_email_valid_chk,
|
|
28
|
+
Sequel.lit("email ~ '^[^,;@ \\r\\n]+@[^,@; \\r\\n]+\\.[^,@; \\r\\n]+$'"))
|
|
29
|
+
column :created_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
|
|
30
|
+
column :deleted_at, :timestamptz
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
create_schema :rodauth_secrets
|
|
34
|
+
|
|
35
|
+
create_table(Sequel[:rodauth_secrets][:account_password_hashes]) do
|
|
36
|
+
foreign_key :id, :accounts, primary_key: true, type: :Bignum
|
|
37
|
+
String :password_hash, null: false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Pass a Sequel qualified identifier, NOT the dotted string, Rodauth's helper
|
|
41
|
+
# won't split on the dot and raises PG::UndefinedTable
|
|
42
|
+
require 'rodauth/migrations'
|
|
43
|
+
Rodauth.create_database_authentication_functions(self,
|
|
44
|
+
argon2: true,
|
|
45
|
+
table_name: Sequel[:rodauth_secrets][:account_password_hashes])
|
|
46
|
+
|
|
47
|
+
# grant_web_privileges! in db.rake only touches public, so the rodauth_secrets grants live here
|
|
48
|
+
web_user = URI.parse(<%= @app.camel %>Config.database.url.to_s).user rescue nil
|
|
49
|
+
if web_user && !web_user.empty?
|
|
50
|
+
quoted = '"' + web_user.gsub('"', '""') + '"'
|
|
51
|
+
run "GRANT USAGE ON SCHEMA rodauth_secrets TO #{quoted}"
|
|
52
|
+
run "GRANT INSERT, UPDATE, DELETE ON rodauth_secrets.account_password_hashes TO #{quoted}"
|
|
53
|
+
# SELECT (id) looks redundant but isn't, PG wants SELECT on every column in an UPDATE WHERE
|
|
54
|
+
# and set_password does UPDATE ... WHERE id = ?. password_hash stays unreadable
|
|
55
|
+
run "GRANT SELECT (id) ON rodauth_secrets.account_password_hashes TO #{quoted}"
|
|
56
|
+
run "GRANT EXECUTE ON FUNCTION rodauth_get_salt(int8) TO #{quoted}"
|
|
57
|
+
run "GRANT EXECUTE ON FUNCTION rodauth_valid_password_hash(int8, text) TO #{quoted}"
|
|
58
|
+
# Usually a no-op on PG 15+, kept as documentation-by-code
|
|
59
|
+
run "REVOKE SELECT ON rodauth_secrets.account_password_hashes FROM PUBLIC"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
down do
|
|
64
|
+
run 'DROP FUNCTION IF EXISTS rodauth_valid_password_hash(int8, text)'
|
|
65
|
+
run 'DROP FUNCTION IF EXISTS rodauth_get_salt(int8)'
|
|
66
|
+
drop_schema :rodauth_secrets, cascade: true
|
|
67
|
+
drop_table :accounts
|
|
68
|
+
drop_table :account_statuses
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
# Append-only, range-partitioned by occurred_at, partitions via rake audit:add_next[N].
|
|
6
|
+
# Requires PostgreSQL 18+ (uuidv7, VIRTUAL generated columns)
|
|
7
|
+
Sequel.migration do
|
|
8
|
+
up do
|
|
9
|
+
log_t = Sequel[:audit_log][:audit_log]
|
|
10
|
+
actor_types_t = Sequel[:audit_log][:actor_types]
|
|
11
|
+
actions_t = Sequel[:audit_log][:actions]
|
|
12
|
+
statuses_t = Sequel[:audit_log][:statuses]
|
|
13
|
+
|
|
14
|
+
create_schema :audit_log
|
|
15
|
+
|
|
16
|
+
create_table(actor_types_t) do
|
|
17
|
+
primary_key :actor_type_id, type: :smallint
|
|
18
|
+
String :code, null: false, unique: true
|
|
19
|
+
String :description
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
create_table(actions_t) do
|
|
23
|
+
primary_key :action_id
|
|
24
|
+
String :code, null: false, unique: true
|
|
25
|
+
String :category
|
|
26
|
+
String :description
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
create_table(statuses_t) do
|
|
30
|
+
primary_key :status_id, type: :smallint
|
|
31
|
+
String :code, null: false, unique: true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
self[actor_types_t].multi_insert([
|
|
35
|
+
{ code: 'user', description: 'End user via web or mobile session' },
|
|
36
|
+
{ code: 'admin', description: 'Admin user via admin panel' },
|
|
37
|
+
{ code: 'api_key', description: 'External API client' },
|
|
38
|
+
{ code: 'system', description: 'Background job or scheduled task' }
|
|
39
|
+
])
|
|
40
|
+
|
|
41
|
+
self[statuses_t].multi_insert([
|
|
42
|
+
{ code: 'success' },
|
|
43
|
+
{ code: 'failure' },
|
|
44
|
+
{ code: 'denied' }
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
# AuditLog.record raises on unregistered codes, an unseeded entry 500s its route
|
|
48
|
+
self[actions_t].multi_insert([
|
|
49
|
+
{ code: 'user.account.create', category: 'auth', description: 'Account created' },
|
|
50
|
+
{ code: 'user.account.verify', category: 'auth', description: 'Account verified' },
|
|
51
|
+
{ code: 'user.account.close', category: 'auth', description: 'Account closed' },
|
|
52
|
+
{ code: 'user.login', category: 'auth', description: 'Fully authenticated session established (post-2FA when required) — status :failure also covers wrong-password attempts' },
|
|
53
|
+
{ code: 'user.password.auth', category: 'auth', description: 'Password verified (first factor)' },
|
|
54
|
+
{ code: 'user.logout', category: 'auth', description: 'Logged out' },
|
|
55
|
+
{ code: 'user.password.change', category: 'auth', description: 'Password changed' },
|
|
56
|
+
{ code: 'user.password.reset', category: 'auth', description: 'Password reset' },
|
|
57
|
+
{ code: 'user.password.reset_request', category: 'auth', description: 'Password reset requested' },
|
|
58
|
+
{ code: 'user.email.change', category: 'auth', description: 'Login/email changed' },
|
|
59
|
+
{ code: 'user.email.verify', category: 'auth', description: 'Login/email change verified' },
|
|
60
|
+
{ code: 'user.otp.setup', category: 'auth', description: 'TOTP set up' },
|
|
61
|
+
{ code: 'user.otp.disable', category: 'auth', description: 'TOTP disabled' },
|
|
62
|
+
{ code: 'user.otp.auth', category: 'auth', description: 'Two-factor authenticated' },
|
|
63
|
+
{ code: 'user.otp.unlock', category: 'auth', description: 'TOTP unlocked' },
|
|
64
|
+
{ code: 'user.recovery_codes.add', category: 'auth', description: 'Recovery codes generated' },
|
|
65
|
+
{ code: 'user.recovery_codes.auth', category: 'auth', description: 'Authenticated via recovery code' },
|
|
66
|
+
{ code: 'user.lockout', category: 'auth', description: 'Account locked out' },
|
|
67
|
+
{ code: 'user.lockout.clear', category: 'auth', description: 'Account unlocked' },
|
|
68
|
+
{ code: 'user.remember.set', category: 'auth', description: 'Remember-me cookie set' },
|
|
69
|
+
{ code: 'user.profile.update', category: 'auth', description: 'Profile attributes changed' },
|
|
70
|
+
{ code: 'user.data.export', category: 'gdpr', description: 'Data export requested' },
|
|
71
|
+
{ code: 'user.data.erase', category: 'gdpr', description: 'Account erasure requested' },
|
|
72
|
+
{ code: 'system.data.export', category: 'gdpr', description: 'Data export delivered' },
|
|
73
|
+
{ code: 'system.data.erase', category: 'gdpr', description: 'Account data erased' },
|
|
74
|
+
{ code: 'authorization.denied', category: 'auth', description: '403 — privilege check failed' },
|
|
75
|
+
{ code: 'admin.impersonate.start', category: 'admin', description: 'Admin started impersonating an account' },
|
|
76
|
+
{ code: 'admin.impersonate.stop', category: 'admin', description: 'Admin stopped impersonating' },
|
|
77
|
+
{ code: 'admin.account.unlock', category: 'admin', description: 'Admin unlocked a locked account' },
|
|
78
|
+
{ code: 'admin.flag.update', category: 'admin', description: 'Admin added or changed a feature flag' },
|
|
79
|
+
# Written by the model hooks in lib/rbac_audit.rb
|
|
80
|
+
{ code: 'rbac.role.create', category: 'rbac', description: 'Role defined' },
|
|
81
|
+
{ code: 'rbac.role.update', category: 'rbac', description: 'Role description changed' },
|
|
82
|
+
{ code: 'rbac.role.delete', category: 'rbac', description: 'Role removed' },
|
|
83
|
+
{ code: 'rbac.privilege.create', category: 'rbac', description: 'Privilege defined' },
|
|
84
|
+
{ code: 'rbac.privilege.update', category: 'rbac', description: 'Privilege description changed' },
|
|
85
|
+
{ code: 'rbac.privilege.delete', category: 'rbac', description: 'Privilege removed' },
|
|
86
|
+
{ code: 'rbac.role_privilege.grant', category: 'rbac', description: 'Privilege added to a role' },
|
|
87
|
+
{ code: 'rbac.role_privilege.revoke', category: 'rbac', description: 'Privilege removed from a role' },
|
|
88
|
+
{ code: 'rbac.account_role.grant', category: 'rbac', description: 'Role granted to an account' },
|
|
89
|
+
{ code: 'rbac.account_role.revoke', category: 'rbac', description: 'Role revoked from an account' },
|
|
90
|
+
{ code: 'rbac.account_privilege.grant', category: 'rbac', description: 'Privilege granted directly to an account' },
|
|
91
|
+
{ code: 'rbac.account_privilege.revoke', category: 'rbac', description: 'Privilege revoked directly from an account' }
|
|
92
|
+
])
|
|
93
|
+
|
|
94
|
+
create_table(log_t, partition_by: :occurred_at, partition_type: :range) do
|
|
95
|
+
column :audit_log_id, :uuid, null: false, default: Sequel.function(:uuidv7)
|
|
96
|
+
column :occurred_at, :timestamptz, null: false, default: Sequel.function(:clock_timestamp)
|
|
97
|
+
|
|
98
|
+
foreign_key :actor_type_id, actor_types_t, type: :smallint, null: false
|
|
99
|
+
Bignum :actor_id
|
|
100
|
+
String :actor_label
|
|
101
|
+
|
|
102
|
+
foreign_key :action_id, actions_t, type: :integer, null: false
|
|
103
|
+
|
|
104
|
+
column :payload, :jsonb
|
|
105
|
+
column :metadata, :jsonb, null: false, default: Sequel.lit("'{}'::jsonb")
|
|
106
|
+
|
|
107
|
+
# Text, NOT :uuid, upstream request-id formats vary (Caddy, CDN, ALB).
|
|
108
|
+
# 49_misc.rb caps at 64 bytes before insert
|
|
109
|
+
String :request_id, size: 64
|
|
110
|
+
String :session_id
|
|
111
|
+
column :ip_address, :inet
|
|
112
|
+
|
|
113
|
+
foreign_key :status_id, statuses_t, type: :smallint, null: false, default: 1
|
|
114
|
+
|
|
115
|
+
primary_key [:audit_log_id, :occurred_at]
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Sequel's DSL emits STORED, VIRTUAL needs raw SQL
|
|
119
|
+
run <<~SQL
|
|
120
|
+
ALTER TABLE audit_log.audit_log
|
|
121
|
+
ADD COLUMN impersonator_id bigint GENERATED ALWAYS AS ((metadata->>'impersonator_id')::bigint) VIRTUAL;
|
|
122
|
+
SQL
|
|
123
|
+
|
|
124
|
+
add_index log_t, [:actor_type_id, :actor_id, Sequel.desc(:occurred_at)],
|
|
125
|
+
name: :idx_audit_log_actor
|
|
126
|
+
add_index log_t, [:action_id, Sequel.desc(:occurred_at)],
|
|
127
|
+
name: :idx_audit_log_action_time
|
|
128
|
+
add_index log_t, :request_id,
|
|
129
|
+
where: Sequel.~(request_id: nil),
|
|
130
|
+
name: :idx_audit_log_request
|
|
131
|
+
|
|
132
|
+
add_index log_t, :occurred_at, type: :brin, name: :idx_audit_log_occurred_brin
|
|
133
|
+
|
|
134
|
+
add_index log_t, Sequel.lit('metadata jsonb_path_ops'),
|
|
135
|
+
type: :gin, name: :idx_audit_log_metadata
|
|
136
|
+
add_index log_t, Sequel.lit('payload jsonb_path_ops'),
|
|
137
|
+
type: :gin, name: :idx_audit_log_payload
|
|
138
|
+
|
|
139
|
+
add_index log_t,
|
|
140
|
+
[Sequel.lit("((metadata->>'impersonator_id')::bigint)"), Sequel.desc(:occurred_at)],
|
|
141
|
+
where: Sequel.lit("metadata ? 'impersonator_id'"),
|
|
142
|
+
name: :idx_audit_log_impersonator
|
|
143
|
+
|
|
144
|
+
create_table(Sequel[:audit_log][:audit_log_default], partition_of: log_t) { default }
|
|
145
|
+
|
|
146
|
+
run <<~SQL
|
|
147
|
+
CREATE OR REPLACE FUNCTION audit_log.create_partition(
|
|
148
|
+
partition_name text,
|
|
149
|
+
range_start date,
|
|
150
|
+
range_end date
|
|
151
|
+
)
|
|
152
|
+
RETURNS void
|
|
153
|
+
LANGUAGE plpgsql
|
|
154
|
+
AS $func$
|
|
155
|
+
BEGIN
|
|
156
|
+
EXECUTE format(
|
|
157
|
+
'CREATE TABLE IF NOT EXISTS audit_log.%I PARTITION OF audit_log.audit_log FOR VALUES FROM (%L) TO (%L)',
|
|
158
|
+
partition_name, range_start, range_end
|
|
159
|
+
);
|
|
160
|
+
END;
|
|
161
|
+
$func$;
|
|
162
|
+
SQL
|
|
163
|
+
|
|
164
|
+
# Usually a no-op on PG 15+, kept as documentation-by-code
|
|
165
|
+
run 'REVOKE UPDATE, DELETE, TRUNCATE ON audit_log.audit_log FROM PUBLIC'
|
|
166
|
+
|
|
167
|
+
web_user = URI.parse(<%= @app.camel %>Config.database.url.to_s).user rescue nil
|
|
168
|
+
if web_user && !web_user.empty?
|
|
169
|
+
quoted = '"' + web_user.gsub('"', '""') + '"'
|
|
170
|
+
run "GRANT USAGE ON SCHEMA audit_log TO #{quoted}"
|
|
171
|
+
run "GRANT INSERT ON audit_log.audit_log TO #{quoted}"
|
|
172
|
+
# Parent grant doesn't reach existing children, and ALTER DEFAULT PRIVILEGES
|
|
173
|
+
# only covers partitions created after this point
|
|
174
|
+
run "GRANT INSERT ON audit_log.audit_log_default TO #{quoted}"
|
|
175
|
+
run "GRANT SELECT ON audit_log.actor_types, audit_log.actions, audit_log.statuses TO #{quoted}"
|
|
176
|
+
run "GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA audit_log TO #{quoted}"
|
|
177
|
+
run "ALTER DEFAULT PRIVILEGES IN SCHEMA audit_log GRANT INSERT ON TABLES TO #{quoted}"
|
|
178
|
+
run "ALTER DEFAULT PRIVILEGES IN SCHEMA audit_log GRANT USAGE, SELECT ON SEQUENCES TO #{quoted}"
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
down do
|
|
183
|
+
drop_schema :audit_log, cascade: true
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# RBAC. An account has a privilege via a direct grant or a role that holds it.
|
|
4
|
+
# Seeds below are dataset inserts, so the lib/rbac_audit.rb hooks don't fire, by design
|
|
5
|
+
Sequel.migration do
|
|
6
|
+
up do
|
|
7
|
+
create_table(:roles) do
|
|
8
|
+
String :role, primary_key: true
|
|
9
|
+
String :description
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
create_table(:privileges) do
|
|
13
|
+
String :privilege, primary_key: true
|
|
14
|
+
String :description
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
create_table(:account_roles) do
|
|
18
|
+
foreign_key :account_id, :accounts, type: :Bignum, null: false
|
|
19
|
+
foreign_key :role_id, :roles, type: :text, null: false
|
|
20
|
+
primary_key %i[account_id role_id]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
create_table(:role_privileges) do
|
|
24
|
+
foreign_key :role_id, :roles, type: :text, null: false
|
|
25
|
+
foreign_key :privilege_id, :privileges, type: :text, null: false
|
|
26
|
+
primary_key %i[role_id privilege_id]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
create_table(:account_privileges) do
|
|
30
|
+
foreign_key :account_id, :accounts, type: :Bignum, null: false
|
|
31
|
+
foreign_key :privilege_id, :privileges, type: :text, null: false
|
|
32
|
+
primary_key %i[account_id privilege_id]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
self[:roles].multi_insert([
|
|
36
|
+
{ role: 'admin', description: 'Full access; every privilege granted by default' },
|
|
37
|
+
{ role: 'user', description: 'Standard end user; no privileges granted by default' }
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
self[:privileges].multi_insert([
|
|
41
|
+
{ privilege: 'accounts.read', description: 'View other accounts' },
|
|
42
|
+
{ privilege: 'accounts.update', description: 'Edit other accounts' },
|
|
43
|
+
{ privilege: 'accounts.delete', description: 'Close other accounts' },
|
|
44
|
+
{ privilege: 'accounts.impersonate', description: 'Sign in as another account' },
|
|
45
|
+
{ privilege: 'accounts.unlock', description: 'Unlock a locked account' },
|
|
46
|
+
{ privilege: 'flags.read', description: 'View feature flags' },
|
|
47
|
+
{ privilege: 'flags.manage', description: 'Change feature flags (enable/disable/%)' }
|
|
48
|
+
])
|
|
49
|
+
|
|
50
|
+
self[:role_privileges].multi_insert([
|
|
51
|
+
{ role_id: 'admin', privilege_id: 'accounts.read' },
|
|
52
|
+
{ role_id: 'admin', privilege_id: 'accounts.update' },
|
|
53
|
+
{ role_id: 'admin', privilege_id: 'accounts.delete' },
|
|
54
|
+
{ role_id: 'admin', privilege_id: 'accounts.impersonate' },
|
|
55
|
+
{ role_id: 'admin', privilege_id: 'accounts.unlock' },
|
|
56
|
+
{ role_id: 'admin', privilege_id: 'flags.read' },
|
|
57
|
+
{ role_id: 'admin', privilege_id: 'flags.manage' }
|
|
58
|
+
])
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
down do
|
|
62
|
+
drop_table :account_privileges
|
|
63
|
+
drop_table :role_privileges
|
|
64
|
+
drop_table :account_roles
|
|
65
|
+
drop_table :privileges
|
|
66
|
+
drop_table :roles
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# ISO 3166-1 country lookup, alpha-2 PK (SE). Created empty, seeded by db/seeds.rb
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
change do
|
|
6
|
+
create_table(:countries) do
|
|
7
|
+
String :iso_code, primary_key: true
|
|
8
|
+
String :iso3_code, null: false
|
|
9
|
+
Integer :iso_numeric, null: false
|
|
10
|
+
String :name, null: false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Calling code per country (SE 46). trunc_code is the national trunk digit
|
|
4
|
+
# dropped when dialing from abroad (0 for Sweden)
|
|
5
|
+
Sequel.migration do
|
|
6
|
+
change do
|
|
7
|
+
create_table(:country_calling_codes) do
|
|
8
|
+
foreign_key :country, :countries, type: String, null: false
|
|
9
|
+
String :calling_code, null: false
|
|
10
|
+
String :trunc_code
|
|
11
|
+
|
|
12
|
+
primary_key [:country]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Prefix dialed FROM this country to reach abroad (00 mostly, 011 from US/Canada), several per country
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
change do
|
|
6
|
+
create_table(:country_exit_codes) do
|
|
7
|
+
foreign_key :country, :countries, type: String, null: false
|
|
8
|
+
String :exit_code, null: false
|
|
9
|
+
|
|
10
|
+
primary_key [:country, :exit_code]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# At most one preferred language per country, enforced by the partial unique index
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
change do
|
|
6
|
+
create_table(:country_languages) do
|
|
7
|
+
foreign_key :country, :countries, type: String, null: false
|
|
8
|
+
foreign_key :language, :languages, type: String, null: false
|
|
9
|
+
TrueClass :preferred, null: false
|
|
10
|
+
|
|
11
|
+
primary_key [:country, :language]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
add_index :country_languages, :country,
|
|
15
|
+
unique: true,
|
|
16
|
+
where: { preferred: true },
|
|
17
|
+
name: :country_languages_preferred_idx
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# IANA time zone (Europe/Stockholm) to country (SE), one row per zone
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
change do
|
|
6
|
+
create_table(:country_time_zones) do
|
|
7
|
+
String :time_zone, primary_key: true
|
|
8
|
+
foreign_key :country, :countries, type: String
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# ISO 4217 currency lookup, alpha-3 PK (SEK)
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
change do
|
|
6
|
+
create_table(:currencies) do
|
|
7
|
+
String :iso_code, primary_key: true
|
|
8
|
+
String :description, null: false
|
|
9
|
+
String :name, null: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|