From eab74a62f7005073d2fb270e0303a267fa2e48b5 Mon Sep 17 00:00:00 2001 From: Thomas Peetz Date: Sat, 28 Jun 2025 18:19:14 +0200 Subject: [PATCH] fix errors in migration scripts --- kontor-rails/Gemfile | 1 + kontor-rails/Gemfile.lock | 9 ++ .../app/controllers/publisher_controller.rb | 4 + kontor-rails/app/helpers/publisher_helper.rb | 2 + kontor-rails/app/models/publisher.rb | 1 + .../app/views/publisher/index.html.erb | 2 + kontor-rails/config/routes.rb | 1 + .../20250626095145_create_publishers.rb | 2 +- .../migrate/20250626095203_create_comics.rb | 2 +- .../migrate/20250626095943_create_issues.rb | 6 +- kontor-rails/db/schema.rb | 96 ++++++++++++++++++- .../controllers/publisher_controller_test.rb | 8 ++ 12 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 kontor-rails/app/controllers/publisher_controller.rb create mode 100644 kontor-rails/app/helpers/publisher_helper.rb create mode 100644 kontor-rails/app/views/publisher/index.html.erb create mode 100644 kontor-rails/test/controllers/publisher_controller_test.rb diff --git a/kontor-rails/Gemfile b/kontor-rails/Gemfile index e0f49f7..139b7ae 100644 --- a/kontor-rails/Gemfile +++ b/kontor-rails/Gemfile @@ -54,6 +54,7 @@ end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" + gem "rails-erd" end group :test do diff --git a/kontor-rails/Gemfile.lock b/kontor-rails/Gemfile.lock index 76b2503..24c94b3 100644 --- a/kontor-rails/Gemfile.lock +++ b/kontor-rails/Gemfile.lock @@ -94,6 +94,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + choice (0.2.0) concurrent-ruby (1.3.5) connection_pool (2.5.3) crass (1.0.6) @@ -230,6 +231,11 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) + rails-erd (1.7.2) + activerecord (>= 4.2) + activesupport (>= 4.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) @@ -278,6 +284,8 @@ GEM rubocop (>= 1.72) rubocop-performance (>= 1.24) rubocop-rails (>= 2.30) + ruby-graphviz (1.2.5) + rexml ruby-progressbar (1.13.0) rubyzip (2.4.1) securerandom (0.4.1) @@ -369,6 +377,7 @@ DEPENDENCIES propshaft puma (>= 5.0) rails (~> 8.0.2) + rails-erd rubocop-rails-omakase selenium-webdriver solid_cable diff --git a/kontor-rails/app/controllers/publisher_controller.rb b/kontor-rails/app/controllers/publisher_controller.rb new file mode 100644 index 0000000..a407b81 --- /dev/null +++ b/kontor-rails/app/controllers/publisher_controller.rb @@ -0,0 +1,4 @@ +class PublisherController < ApplicationController + def index + end +end diff --git a/kontor-rails/app/helpers/publisher_helper.rb b/kontor-rails/app/helpers/publisher_helper.rb new file mode 100644 index 0000000..0284dee --- /dev/null +++ b/kontor-rails/app/helpers/publisher_helper.rb @@ -0,0 +1,2 @@ +module PublisherHelper +end diff --git a/kontor-rails/app/models/publisher.rb b/kontor-rails/app/models/publisher.rb index eacaae0..6a92294 100644 --- a/kontor-rails/app/models/publisher.rb +++ b/kontor-rails/app/models/publisher.rb @@ -1,3 +1,4 @@ class Publisher < ApplicationRecord + has_many :imprints, class_name: "Publisher", foreign_key: "parent_publisher_id" has_many :comics end diff --git a/kontor-rails/app/views/publisher/index.html.erb b/kontor-rails/app/views/publisher/index.html.erb new file mode 100644 index 0000000..b1231ad --- /dev/null +++ b/kontor-rails/app/views/publisher/index.html.erb @@ -0,0 +1,2 @@ +

Publisher#index

+

Find me in app/views/publisher/index.html.erb

diff --git a/kontor-rails/config/routes.rb b/kontor-rails/config/routes.rb index 48254e8..46aa3ec 100644 --- a/kontor-rails/config/routes.rb +++ b/kontor-rails/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + get "/comic/publishers/", to: "publisher#index" # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. diff --git a/kontor-rails/db/migrate/20250626095145_create_publishers.rb b/kontor-rails/db/migrate/20250626095145_create_publishers.rb index 7129b35..8cd1a7d 100644 --- a/kontor-rails/db/migrate/20250626095145_create_publishers.rb +++ b/kontor-rails/db/migrate/20250626095145_create_publishers.rb @@ -6,7 +6,7 @@ class CreatePublishers < ActiveRecord::Migration[8.0] t.integer :version t.string :name t.string :weblink - t.belongs_to :publisher, optional: true + t.string :parent_publisher_id end change_column :publishers, :id, :string end diff --git a/kontor-rails/db/migrate/20250626095203_create_comics.rb b/kontor-rails/db/migrate/20250626095203_create_comics.rb index 592f7c8..d9e8cb5 100644 --- a/kontor-rails/db/migrate/20250626095203_create_comics.rb +++ b/kontor-rails/db/migrate/20250626095203_create_comics.rb @@ -8,7 +8,7 @@ class CreateComics < ActiveRecord::Migration[8.0] t.boolean :current_order t.boolean :completed t.string :weblink - t.belongs_to :publisher, foreign_key: true + t.belongs_to :publisher end change_column :comics, :id, :string end diff --git a/kontor-rails/db/migrate/20250626095943_create_issues.rb b/kontor-rails/db/migrate/20250626095943_create_issues.rb index 548af3a..c4a1420 100644 --- a/kontor-rails/db/migrate/20250626095943_create_issues.rb +++ b/kontor-rails/db/migrate/20250626095943_create_issues.rb @@ -9,9 +9,9 @@ class CreateIssues < ActiveRecord::Migration[8.0] t.datetime :published_on t.boolean :in_stock t.boolean :is_read - t.belongs_to :comic, foreign_key: true - t.belongs_to :volume, foreign_key: true - t.belongs_to :story_arc, foreign_key: true + t.belongs_to :comic + t.belongs_to :volume + t.belongs_to :story_arc end change_column :issues, :id, :string end diff --git a/kontor-rails/db/schema.rb b/kontor-rails/db/schema.rb index 0f651a4..f3a5aaa 100644 --- a/kontor-rails/db/schema.rb +++ b/kontor-rails/db/schema.rb @@ -10,5 +10,99 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 0) do +ActiveRecord::Schema[8.0].define(version: 2025_06_26_100213) do + create_table "artists", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "comic_works", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "comics", id: false, force: :cascade do |t| + t.string "id" + t.datetime "created_date" + t.datetime "last_modified_date" + t.integer "version" + t.string "title" + t.boolean "current_order" + t.boolean "completed" + t.string "weblink" + t.integer "publisher_id" + t.index ["publisher_id"], name: "index_comics_on_publisher_id" + end + + create_table "issue_works", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "issues", id: false, force: :cascade do |t| + t.string "id" + t.datetime "created_date" + t.datetime "last_modified_date" + t.integer "version" + t.string "issueNumber" + t.string "title" + t.datetime "published_on" + t.boolean "in_stock" + t.boolean "is_read" + t.integer "comic_id" + t.integer "volume_id" + t.integer "story_arc_id" + t.index ["comic_id"], name: "index_issues_on_comic_id" + t.index ["story_arc_id"], name: "index_issues_on_story_arc_id" + t.index ["volume_id"], name: "index_issues_on_volume_id" + end + + create_table "publishers", id: false, force: :cascade do |t| + t.string "id" + t.datetime "created_date" + t.datetime "last_modified_date" + t.integer "version" + t.string "name" + t.string "weblink" + t.string "parent_publisher_id" + end + + create_table "story_arcs", id: false, force: :cascade do |t| + t.string "id" + t.datetime "created_date" + t.datetime "last_modified_date" + t.integer "version" + t.string "name" + t.integer "comic_id" + t.index ["comic_id"], name: "index_story_arcs_on_comic_id" + end + + create_table "trade_paperbacks", id: false, force: :cascade do |t| + t.string "id" + t.datetime "created_date" + t.datetime "last_modified_date" + t.integer "version" + t.string "name" + t.integer "issue_start" + t.integer "issue_end" + t.integer "comic_id" + t.index ["comic_id"], name: "index_trade_paperbacks_on_comic_id" + end + + create_table "volumes", id: false, force: :cascade do |t| + t.string "id" + t.datetime "created_date" + t.datetime "last_modified_date" + t.integer "version" + t.string "name" + t.integer "comic_id" + t.index ["comic_id"], name: "index_volumes_on_comic_id" + end + + create_table "worktypes", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end end diff --git a/kontor-rails/test/controllers/publisher_controller_test.rb b/kontor-rails/test/controllers/publisher_controller_test.rb new file mode 100644 index 0000000..48b9889 --- /dev/null +++ b/kontor-rails/test/controllers/publisher_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class PublisherControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get publisher_index_url + assert_response :success + end +end