1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 23:59:40 +02:00

Initial commit

This commit is contained in:
Josh Pigford 2024-02-02 09:05:04 -06:00
commit 99de24ac70
147 changed files with 3519 additions and 0 deletions

View file

@ -0,0 +1,5 @@
class EnableUuid < ActiveRecord::Migration[7.2]
def change
enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
end
end

View file

@ -0,0 +1,9 @@
class CreateFamilies < ActiveRecord::Migration[7.2]
def change
create_table :families, id: :uuid do |t|
t.string :name
t.timestamps
end
end
end

View file

@ -0,0 +1,13 @@
class CreateUsers < ActiveRecord::Migration[7.2]
def change
create_table :users, id: :uuid do |t|
t.references :family, null: false, foreign_key: true, type: :uuid
t.string :first_name
t.string :last_name
t.string :email
t.string :password_digest
t.timestamps
end
end
end

View file

@ -0,0 +1,16 @@
class CreateAccounts < ActiveRecord::Migration[7.2]
def change
create_table :accounts, id: :uuid do |t|
t.string :type
t.string :subtype
t.references :family, null: false, foreign_key: true, type: :uuid
t.string :name
t.bigint :balance, default: 0
t.string :currency, default: "USD"
t.timestamps
end
add_index :accounts, :type
end
end

50
db/schema.rb generated Normal file
View file

@ -0,0 +1,50 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2024_02_02_015428) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
create_table "accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "type"
t.string "subtype"
t.uuid "family_id", null: false
t.string "name"
t.bigint "balance", default: 0
t.string "currency", default: "USD"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["family_id"], name: "index_accounts_on_family_id"
t.index ["type"], name: "index_accounts_on_type"
end
create_table "families", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "family_id", null: false
t.string "first_name"
t.string "last_name"
t.string "email"
t.string "password_digest"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["family_id"], name: "index_users_on_family_id"
end
add_foreign_key "accounts", "families"
add_foreign_key "users", "families"
end

9
db/seeds.rb Normal file
View file

@ -0,0 +1,9 @@
# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Example:
#
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# MovieGenre.find_or_create_by!(name: genre_name)
# end