Skip to content

Commit

Permalink
generated model for Expanse, Budget, Category
Browse files Browse the repository at this point in the history
  • Loading branch information
Un-dev committed Dec 18, 2021
1 parent 0a15583 commit c20bdc7
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/budget.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Budget < ApplicationRecord
end
2 changes: 2 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Category < ApplicationRecord
end
2 changes: 2 additions & 0 deletions app/models/expense.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Expense < ApplicationRecord
end
9 changes: 9 additions & 0 deletions db/migrate/20211218205541_create_category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateCategory < ActiveRecord::Migration[6.1]
def change
create_table :categories do |t|
t.string :title

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20211218205550_create_budget.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateBudget < ActiveRecord::Migration[6.1]
def change
create_table :budgets do |t|
t.date :starts_at
t.date :ends_at

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20211218205555_create_expense.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateExpense < ActiveRecord::Migration[6.1]
def change
create_table :expenses do |t|
t.date :date
t.string :title
t.integer :amount
t.references :category, index: true, foreign_key: true

t.timestamps
end
end
end
42 changes: 42 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions log/development.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
 (0.9ms) CREATE DATABASE "budget_dev" ENCODING = 'utf8'
 (123.4ms) CREATE DATABASE "budget_test" ENCODING = 'utf8'
 (12.2ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
 (2.0ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
 (0.2ms) SELECT pg_try_advisory_lock(6586007212054593750)
 (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Migrating to CreateCategory (20211218205541)
TRANSACTION (0.2ms) BEGIN
 (8.1ms) CREATE TABLE "categories" ("id" bigserial primary key, "title" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
ActiveRecord::SchemaMigration Create (1.1ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20211218205541"]]
TRANSACTION (0.5ms) COMMIT
Migrating to CreateBudget (20211218205550)
TRANSACTION (0.5ms) BEGIN
 (5.7ms) CREATE TABLE "budgets" ("id" bigserial primary key, "starts_at" date, "ends_at" date, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20211218205550"]]
TRANSACTION (0.2ms) COMMIT
Migrating to CreateExpense (20211218205555)
 (0.8ms) SELECT pg_advisory_unlock(6586007212054593750)
 (0.2ms) SELECT pg_try_advisory_lock(6586007212054593750)
 (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Migrating to CreateExpense (20211218205555)
TRANSACTION (0.1ms) BEGIN
 (10.6ms) CREATE TABLE "expenses" ("id" bigserial primary key, "date" date, "title" character varying, "amount" integer, "category_id" bigint, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL, CONSTRAINT "fk_rails_06966d0da0"
FOREIGN KEY ("category_id")
REFERENCES "categories" ("id")
)
 (0.6ms) CREATE INDEX "index_expenses_on_category_id" ON "expenses" ("category_id")
ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20211218205555"]]
TRANSACTION (0.6ms) COMMIT
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
TRANSACTION (0.1ms) BEGIN
ActiveRecord::InternalMetadata Create (0.8ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2021-12-18 21:20:21.741362"], ["updated_at", "2021-12-18 21:20:21.741362"]]
TRANSACTION (0.2ms) COMMIT
 (0.2ms) SELECT pg_advisory_unlock(6586007212054593750)
 (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
7 changes: 7 additions & 0 deletions test/models/budget_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class BudgetTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/category_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class CategoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/expense_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class ExpenseTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit c20bdc7

Please sign in to comment.