From 3d2a6b0d754bc1220ee9662de6b653cbc65a343f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Tue, 30 May 2023 00:40:43 +0900 Subject: [PATCH 1/8] [mod] change db mysql->postgres (#196) --- api/Gemfile | 3 ++- api/Gemfile.lock | 4 ++-- api/config/database.yml | 7 +++---- api/db/schema.rb | 39 +++++++++++++++++++++------------------ docker-compose.yml | 35 +++++++++++------------------------ 5 files changed, 39 insertions(+), 49 deletions(-) diff --git a/api/Gemfile b/api/Gemfile index d77f7f2..14aa49b 100644 --- a/api/Gemfile +++ b/api/Gemfile @@ -6,7 +6,8 @@ ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.3', '>= 6.1.3.1' # Use mysql as the database for Active Record -gem 'mysql2', '~> 0.5' +# gem 'mysql2', '~> 0.5' +gem 'pg', '~> 1.1' # Use Puma as the app server gem 'puma', '~> 5.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/api/Gemfile.lock b/api/Gemfile.lock index 029c76b..3258458 100644 --- a/api/Gemfile.lock +++ b/api/Gemfile.lock @@ -108,12 +108,12 @@ GEM mini_portile2 (2.6.1) minitest (5.14.4) msgpack (1.4.2) - mysql2 (0.5.3) nio4r (2.5.8) nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) orm_adapter (0.5.0) + pg (1.5.3) puma (5.5.2) nio4r (~> 2.0) racc (1.6.0) @@ -196,7 +196,7 @@ DEPENDENCIES devise_token_auth dotenv-rails listen (~> 3.3) - mysql2 (~> 0.5) + pg (~> 1.1) puma (~> 5.0) rack-cors rails (~> 6.1.3, >= 6.1.3.1) diff --git a/api/config/database.yml b/api/config/database.yml index 0e4286a..d19f565 100644 --- a/api/config/database.yml +++ b/api/config/database.yml @@ -10,13 +10,12 @@ # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default - adapter: mysql2 - encoding: utf8mb4 + adapter: postgresql + encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: root + username: seeds password: password host: seeds_db - socket: /tmp/myapp.sock development: <<: *default diff --git a/api/db/schema.rb b/api/db/schema.rb index f701595..3bc495f 100644 --- a/api/db/schema.rb +++ b/api/db/schema.rb @@ -12,20 +12,23 @@ ActiveRecord::Schema.define(version: 2023_02_21_091509) do - create_table "bureaus", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "bureaus", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "categories", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "categories", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "detail" end - create_table "chapters", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "chapters", force: :cascade do |t| t.string "title" t.text "content" t.text "homework" @@ -35,14 +38,14 @@ t.integer "order" end - create_table "curriculum_skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "curriculum_skills", force: :cascade do |t| t.integer "curriculum_id" t.integer "skill_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "curriculums", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "curriculums", force: :cascade do |t| t.string "title" t.integer "skill_ids" t.datetime "created_at", precision: 6, null: false @@ -50,26 +53,26 @@ t.text "graduation_assignment" end - create_table "departments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "departments", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "grades", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "grades", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "project_skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "project_skills", force: :cascade do |t| t.integer "project_id" t.integer "skill_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "project_users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "project_users", force: :cascade do |t| t.integer "project_id" t.integer "user_id" t.integer "role_id" @@ -77,7 +80,7 @@ t.datetime "updated_at", precision: 6, null: false end - create_table "projects", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "projects", force: :cascade do |t| t.string "name" t.string "detail" t.string "icon_name" @@ -87,7 +90,7 @@ t.datetime "updated_at", precision: 6, null: false end - create_table "records", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "records", force: :cascade do |t| t.string "title" t.text "content" t.text "homework" @@ -97,13 +100,13 @@ t.integer "chapter_id" end - create_table "roles", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "roles", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "skills", force: :cascade do |t| t.string "name" t.string "detail" t.integer "category_id" @@ -112,20 +115,20 @@ t.integer "type_id" end - create_table "teachers", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "teachers", force: :cascade do |t| t.integer "user_id" t.integer "record_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "types", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "types", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "user_details", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "user_details", force: :cascade do |t| t.integer "user_id" t.integer "grade_id" t.integer "department_id" @@ -144,14 +147,14 @@ t.integer "type_id" end - create_table "user_skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "user_skills", force: :cascade do |t| t.integer "user_id" t.integer "skill_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "users", force: :cascade do |t| t.string "provider", default: "email", null: false t.string "uid", default: "", null: false t.string "encrypted_password", default: "", null: false diff --git a/docker-compose.yml b/docker-compose.yml index 530511d..4faa05f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,14 @@ version: "3" services: seeds_db: - image: mysql:8.0 - container_name: "seeds_db" - environment: - MYSQL_ROOT_PASSWORD: password - ports: - - "3306:3306" - command: --default-authentication-plugin=mysql_native_password + image: postgres:12 volumes: - - mysql-data:/var/lib/mysql + - mysql-data:/var/lib/postgresql/data + environment: + POSTGRES_DB: myapp_development + POSTGRES_USER: seeds + POSTGRES_PASSWORD: password + POSTGRES_HOST_AUTH_METHOD: trust seeds_api: build: ./api @@ -20,9 +19,8 @@ services: volumes: - ./api:/myapp depends_on: - - seeds_db - stdin_open: true - tty: true + seeds_db: + condition: service_started seeds_view: build: ./view @@ -32,22 +30,11 @@ services: command: sh -c "npm install && npm run dev" volumes: - ./view:/app - stdin_open: true - tty: true environment: - SEEDS_API_URI=http://localhost:3000 - - # 定期実行用コンテナ - cron: - image: nutmeg-seeds-seeds_api:latest - command: > - sh -c "whenever --update-cron && - cron -f -l 2" - restart: always - volumes: - - ./api:/usr/src/app depends_on: - - seeds_api + seeds_api: + condition: service_started volumes: mysql-data: From de594c924fc3fbb6a5db18970c12813837ad4157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Tue, 30 May 2023 00:54:44 +0900 Subject: [PATCH 2/8] [add] hasura init (#196) --- .docker/hasura.Dockerfile | 3 +++ docker-compose.yml | 16 ++++++++++++++++ hasura/config.yaml | 6 ++++++ hasura/metadata/actions.graphql | 0 hasura/metadata/actions.yaml | 6 ++++++ hasura/metadata/allow_list.yaml | 1 + hasura/metadata/cron_triggers.yaml | 1 + hasura/metadata/databases/databases.yaml | 1 + hasura/metadata/query_collections.yaml | 1 + hasura/metadata/remote_schemas.yaml | 1 + hasura/metadata/version.yaml | 1 + 11 files changed, 37 insertions(+) create mode 100644 .docker/hasura.Dockerfile create mode 100644 hasura/config.yaml create mode 100644 hasura/metadata/actions.graphql create mode 100644 hasura/metadata/actions.yaml create mode 100644 hasura/metadata/allow_list.yaml create mode 100644 hasura/metadata/cron_triggers.yaml create mode 100644 hasura/metadata/databases/databases.yaml create mode 100644 hasura/metadata/query_collections.yaml create mode 100644 hasura/metadata/remote_schemas.yaml create mode 100644 hasura/metadata/version.yaml diff --git a/.docker/hasura.Dockerfile b/.docker/hasura.Dockerfile new file mode 100644 index 0000000..9ad685b --- /dev/null +++ b/.docker/hasura.Dockerfile @@ -0,0 +1,3 @@ +FROM hasura/graphql-engine:latest +WORKDIR /hasura +RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash diff --git a/docker-compose.yml b/docker-compose.yml index 4faa05f..6c3f489 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,22 @@ services: seeds_db: condition: service_started + hasura: + build: + context: .docker + dockerfile: hasura.Dockerfile + container_name: "seeds_hasura" + ports: + - "8082:8080" + restart: always + volumes: + - ./hasura:/hasura + environment: + HASURA_GRAPHQL_ENABLE_CONSOLE: "true" + HASURA_GRAPHQL_DATABASE_URL: postgres://seeds:password@seeds_db:5432/myapp_development + HASURA_GRAPHQL_DEV_MODE: "true" + HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log + seeds_view: build: ./view container_name: "seeds_view" diff --git a/hasura/config.yaml b/hasura/config.yaml new file mode 100644 index 0000000..1ab15e9 --- /dev/null +++ b/hasura/config.yaml @@ -0,0 +1,6 @@ +version: 3 +endpoint: http://hasura:8080 +metadata_directory: metadata +actions: + kind: synchronous + handler_webhook_baseurl: http://localhost:3000 diff --git a/hasura/metadata/actions.graphql b/hasura/metadata/actions.graphql new file mode 100644 index 0000000..e69de29 diff --git a/hasura/metadata/actions.yaml b/hasura/metadata/actions.yaml new file mode 100644 index 0000000..1979211 --- /dev/null +++ b/hasura/metadata/actions.yaml @@ -0,0 +1,6 @@ +actions: [] +custom_types: + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/hasura/metadata/allow_list.yaml b/hasura/metadata/allow_list.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/allow_list.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/cron_triggers.yaml b/hasura/metadata/cron_triggers.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/cron_triggers.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/databases/databases.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/query_collections.yaml b/hasura/metadata/query_collections.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/query_collections.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/remote_schemas.yaml b/hasura/metadata/remote_schemas.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/remote_schemas.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/version.yaml b/hasura/metadata/version.yaml new file mode 100644 index 0000000..0a70aff --- /dev/null +++ b/hasura/metadata/version.yaml @@ -0,0 +1 @@ +version: 3 From 13a8b25037a1d903afd79c6d450c518dc2c76b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Tue, 30 May 2023 01:09:12 +0900 Subject: [PATCH 3/8] [add] hasura metadata export (#196) --- hasura/metadata/actions.yaml | 8 ++++---- hasura/metadata/api_limits.yaml | 1 + hasura/metadata/backend_configs.yaml | 1 + hasura/metadata/databases/databases.yaml | 15 ++++++++++++++- .../default/tables/public_bureaus.yaml | 3 +++ .../default/tables/public_categories.yaml | 3 +++ .../default/tables/public_chapters.yaml | 3 +++ .../tables/public_curriculum_skills.yaml | 3 +++ .../default/tables/public_curriculums.yaml | 3 +++ .../default/tables/public_departments.yaml | 3 +++ .../default/tables/public_grades.yaml | 3 +++ .../default/tables/public_project_skills.yaml | 3 +++ .../default/tables/public_project_users.yaml | 3 +++ .../default/tables/public_projects.yaml | 3 +++ .../default/tables/public_records.yaml | 3 +++ .../databases/default/tables/public_roles.yaml | 3 +++ .../default/tables/public_skills.yaml | 3 +++ .../default/tables/public_teachers.yaml | 3 +++ .../databases/default/tables/public_types.yaml | 3 +++ .../default/tables/public_user_details.yaml | 3 +++ .../default/tables/public_user_skills.yaml | 3 +++ .../databases/default/tables/public_users.yaml | 3 +++ .../databases/default/tables/tables.yaml | 18 ++++++++++++++++++ .../metadata/graphql_schema_introspection.yaml | 1 + hasura/metadata/inherited_roles.yaml | 1 + hasura/metadata/metrics_config.yaml | 1 + hasura/metadata/network.yaml | 1 + hasura/metadata/opentelemetry.yaml | 1 + hasura/metadata/rest_endpoints.yaml | 1 + 29 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 hasura/metadata/api_limits.yaml create mode 100644 hasura/metadata/backend_configs.yaml create mode 100644 hasura/metadata/databases/default/tables/public_bureaus.yaml create mode 100644 hasura/metadata/databases/default/tables/public_categories.yaml create mode 100644 hasura/metadata/databases/default/tables/public_chapters.yaml create mode 100644 hasura/metadata/databases/default/tables/public_curriculum_skills.yaml create mode 100644 hasura/metadata/databases/default/tables/public_curriculums.yaml create mode 100644 hasura/metadata/databases/default/tables/public_departments.yaml create mode 100644 hasura/metadata/databases/default/tables/public_grades.yaml create mode 100644 hasura/metadata/databases/default/tables/public_project_skills.yaml create mode 100644 hasura/metadata/databases/default/tables/public_project_users.yaml create mode 100644 hasura/metadata/databases/default/tables/public_projects.yaml create mode 100644 hasura/metadata/databases/default/tables/public_records.yaml create mode 100644 hasura/metadata/databases/default/tables/public_roles.yaml create mode 100644 hasura/metadata/databases/default/tables/public_skills.yaml create mode 100644 hasura/metadata/databases/default/tables/public_teachers.yaml create mode 100644 hasura/metadata/databases/default/tables/public_types.yaml create mode 100644 hasura/metadata/databases/default/tables/public_user_details.yaml create mode 100644 hasura/metadata/databases/default/tables/public_user_skills.yaml create mode 100644 hasura/metadata/databases/default/tables/public_users.yaml create mode 100644 hasura/metadata/databases/default/tables/tables.yaml create mode 100644 hasura/metadata/graphql_schema_introspection.yaml create mode 100644 hasura/metadata/inherited_roles.yaml create mode 100644 hasura/metadata/metrics_config.yaml create mode 100644 hasura/metadata/network.yaml create mode 100644 hasura/metadata/opentelemetry.yaml create mode 100644 hasura/metadata/rest_endpoints.yaml diff --git a/hasura/metadata/actions.yaml b/hasura/metadata/actions.yaml index 1979211..1edb4c2 100644 --- a/hasura/metadata/actions.yaml +++ b/hasura/metadata/actions.yaml @@ -1,6 +1,6 @@ actions: [] custom_types: - enums: [] - input_objects: [] - objects: [] - scalars: [] + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/hasura/metadata/api_limits.yaml b/hasura/metadata/api_limits.yaml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/hasura/metadata/api_limits.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/backend_configs.yaml b/hasura/metadata/backend_configs.yaml new file mode 100644 index 0000000..47b48f7 --- /dev/null +++ b/hasura/metadata/backend_configs.yaml @@ -0,0 +1 @@ +dataconnector: {} diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml index fe51488..65a11b2 100644 --- a/hasura/metadata/databases/databases.yaml +++ b/hasura/metadata/databases/databases.yaml @@ -1 +1,14 @@ -[] +- name: default + kind: postgres + configuration: + connection_info: + database_url: + from_env: HASURA_GRAPHQL_DATABASE_URL + isolation_level: read-committed + pool_settings: + connection_lifetime: 600 + idle_timeout: 180 + max_connections: 50 + retries: 1 + use_prepared_statements: true + tables: "!include default/tables/tables.yaml" diff --git a/hasura/metadata/databases/default/tables/public_bureaus.yaml b/hasura/metadata/databases/default/tables/public_bureaus.yaml new file mode 100644 index 0000000..ea336b9 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_bureaus.yaml @@ -0,0 +1,3 @@ +table: + name: bureaus + schema: public diff --git a/hasura/metadata/databases/default/tables/public_categories.yaml b/hasura/metadata/databases/default/tables/public_categories.yaml new file mode 100644 index 0000000..9b2afe9 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_categories.yaml @@ -0,0 +1,3 @@ +table: + name: categories + schema: public diff --git a/hasura/metadata/databases/default/tables/public_chapters.yaml b/hasura/metadata/databases/default/tables/public_chapters.yaml new file mode 100644 index 0000000..de6d082 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_chapters.yaml @@ -0,0 +1,3 @@ +table: + name: chapters + schema: public diff --git a/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml b/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml new file mode 100644 index 0000000..6ba5a84 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml @@ -0,0 +1,3 @@ +table: + name: curriculum_skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_curriculums.yaml b/hasura/metadata/databases/default/tables/public_curriculums.yaml new file mode 100644 index 0000000..04ec991 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_curriculums.yaml @@ -0,0 +1,3 @@ +table: + name: curriculums + schema: public diff --git a/hasura/metadata/databases/default/tables/public_departments.yaml b/hasura/metadata/databases/default/tables/public_departments.yaml new file mode 100644 index 0000000..12a7bdd --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_departments.yaml @@ -0,0 +1,3 @@ +table: + name: departments + schema: public diff --git a/hasura/metadata/databases/default/tables/public_grades.yaml b/hasura/metadata/databases/default/tables/public_grades.yaml new file mode 100644 index 0000000..11c9b0e --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_grades.yaml @@ -0,0 +1,3 @@ +table: + name: grades + schema: public diff --git a/hasura/metadata/databases/default/tables/public_project_skills.yaml b/hasura/metadata/databases/default/tables/public_project_skills.yaml new file mode 100644 index 0000000..37db0b1 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_project_skills.yaml @@ -0,0 +1,3 @@ +table: + name: project_skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_project_users.yaml b/hasura/metadata/databases/default/tables/public_project_users.yaml new file mode 100644 index 0000000..b26f1e2 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_project_users.yaml @@ -0,0 +1,3 @@ +table: + name: project_users + schema: public diff --git a/hasura/metadata/databases/default/tables/public_projects.yaml b/hasura/metadata/databases/default/tables/public_projects.yaml new file mode 100644 index 0000000..a1fcae4 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_projects.yaml @@ -0,0 +1,3 @@ +table: + name: projects + schema: public diff --git a/hasura/metadata/databases/default/tables/public_records.yaml b/hasura/metadata/databases/default/tables/public_records.yaml new file mode 100644 index 0000000..5c5285c --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_records.yaml @@ -0,0 +1,3 @@ +table: + name: records + schema: public diff --git a/hasura/metadata/databases/default/tables/public_roles.yaml b/hasura/metadata/databases/default/tables/public_roles.yaml new file mode 100644 index 0000000..c2e0c5b --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_roles.yaml @@ -0,0 +1,3 @@ +table: + name: roles + schema: public diff --git a/hasura/metadata/databases/default/tables/public_skills.yaml b/hasura/metadata/databases/default/tables/public_skills.yaml new file mode 100644 index 0000000..92e08c9 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_skills.yaml @@ -0,0 +1,3 @@ +table: + name: skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_teachers.yaml b/hasura/metadata/databases/default/tables/public_teachers.yaml new file mode 100644 index 0000000..b19c55a --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_teachers.yaml @@ -0,0 +1,3 @@ +table: + name: teachers + schema: public diff --git a/hasura/metadata/databases/default/tables/public_types.yaml b/hasura/metadata/databases/default/tables/public_types.yaml new file mode 100644 index 0000000..6cab40e --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_types.yaml @@ -0,0 +1,3 @@ +table: + name: types + schema: public diff --git a/hasura/metadata/databases/default/tables/public_user_details.yaml b/hasura/metadata/databases/default/tables/public_user_details.yaml new file mode 100644 index 0000000..3f0f243 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_user_details.yaml @@ -0,0 +1,3 @@ +table: + name: user_details + schema: public diff --git a/hasura/metadata/databases/default/tables/public_user_skills.yaml b/hasura/metadata/databases/default/tables/public_user_skills.yaml new file mode 100644 index 0000000..db0987d --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_user_skills.yaml @@ -0,0 +1,3 @@ +table: + name: user_skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_users.yaml b/hasura/metadata/databases/default/tables/public_users.yaml new file mode 100644 index 0000000..52de1e0 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_users.yaml @@ -0,0 +1,3 @@ +table: + name: users + schema: public diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml new file mode 100644 index 0000000..aa0105e --- /dev/null +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -0,0 +1,18 @@ +- "!include public_bureaus.yaml" +- "!include public_categories.yaml" +- "!include public_chapters.yaml" +- "!include public_curriculum_skills.yaml" +- "!include public_curriculums.yaml" +- "!include public_departments.yaml" +- "!include public_grades.yaml" +- "!include public_project_skills.yaml" +- "!include public_project_users.yaml" +- "!include public_projects.yaml" +- "!include public_records.yaml" +- "!include public_roles.yaml" +- "!include public_skills.yaml" +- "!include public_teachers.yaml" +- "!include public_types.yaml" +- "!include public_user_details.yaml" +- "!include public_user_skills.yaml" +- "!include public_users.yaml" diff --git a/hasura/metadata/graphql_schema_introspection.yaml b/hasura/metadata/graphql_schema_introspection.yaml new file mode 100644 index 0000000..61a4dca --- /dev/null +++ b/hasura/metadata/graphql_schema_introspection.yaml @@ -0,0 +1 @@ +disabled_for_roles: [] diff --git a/hasura/metadata/inherited_roles.yaml b/hasura/metadata/inherited_roles.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/inherited_roles.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/metrics_config.yaml b/hasura/metadata/metrics_config.yaml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/hasura/metadata/metrics_config.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/network.yaml b/hasura/metadata/network.yaml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/hasura/metadata/network.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/opentelemetry.yaml b/hasura/metadata/opentelemetry.yaml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/hasura/metadata/opentelemetry.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/rest_endpoints.yaml b/hasura/metadata/rest_endpoints.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura/metadata/rest_endpoints.yaml @@ -0,0 +1 @@ +[] From df17b414e054bf9c90c03f7fb6dbbb1a0e03dea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Tue, 30 May 2023 01:12:45 +0900 Subject: [PATCH 4/8] [add] hasura migrate create "init" --from-server (#196) --- .../default/1685376660170_init/up.sql | 343 ++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 hasura/migrations/default/1685376660170_init/up.sql diff --git a/hasura/migrations/default/1685376660170_init/up.sql b/hasura/migrations/default/1685376660170_init/up.sql new file mode 100644 index 0000000..91f77cd --- /dev/null +++ b/hasura/migrations/default/1685376660170_init/up.sql @@ -0,0 +1,343 @@ +SET check_function_bodies = false; +CREATE TABLE public.bureaus ( + id bigint NOT NULL, + name character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.bureaus_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.bureaus_id_seq OWNED BY public.bureaus.id; +CREATE TABLE public.categories ( + id bigint NOT NULL, + name character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + detail character varying +); +CREATE SEQUENCE public.categories_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.categories_id_seq OWNED BY public.categories.id; +CREATE TABLE public.chapters ( + id bigint NOT NULL, + title character varying, + content text, + homework text, + curriculum_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + "order" integer +); +CREATE SEQUENCE public.chapters_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.chapters_id_seq OWNED BY public.chapters.id; +CREATE TABLE public.curriculum_skills ( + id bigint NOT NULL, + curriculum_id integer, + skill_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.curriculum_skills_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.curriculum_skills_id_seq OWNED BY public.curriculum_skills.id; +CREATE TABLE public.curriculums ( + id bigint NOT NULL, + title character varying, + skill_ids integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + graduation_assignment text +); +CREATE SEQUENCE public.curriculums_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.curriculums_id_seq OWNED BY public.curriculums.id; +CREATE TABLE public.departments ( + id bigint NOT NULL, + name character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.departments_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.departments_id_seq OWNED BY public.departments.id; +CREATE TABLE public.grades ( + id bigint NOT NULL, + name character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.grades_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.grades_id_seq OWNED BY public.grades.id; +CREATE TABLE public.project_skills ( + id bigint NOT NULL, + project_id integer, + skill_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.project_skills_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.project_skills_id_seq OWNED BY public.project_skills.id; +CREATE TABLE public.project_users ( + id bigint NOT NULL, + project_id integer, + user_id integer, + role_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.project_users_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.project_users_id_seq OWNED BY public.project_users.id; +CREATE TABLE public.projects ( + id bigint NOT NULL, + name character varying, + detail character varying, + icon_name character varying, + github character varying, + remark character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.projects_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.projects_id_seq OWNED BY public.projects.id; +CREATE TABLE public.records ( + id bigint NOT NULL, + title character varying, + content text, + homework text, + user_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + chapter_id integer +); +CREATE SEQUENCE public.records_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.records_id_seq OWNED BY public.records.id; +CREATE TABLE public.roles ( + id bigint NOT NULL, + name character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.roles_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id; +CREATE TABLE public.skills ( + id bigint NOT NULL, + name character varying, + detail character varying, + category_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + type_id integer +); +CREATE SEQUENCE public.skills_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.skills_id_seq OWNED BY public.skills.id; +CREATE TABLE public.teachers ( + id bigint NOT NULL, + user_id integer, + record_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.teachers_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.teachers_id_seq OWNED BY public.teachers.id; +CREATE TABLE public.types ( + id bigint NOT NULL, + name character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.types_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.types_id_seq OWNED BY public.types.id; +CREATE TABLE public.user_details ( + id bigint NOT NULL, + user_id integer, + grade_id integer, + department_id integer, + bureau_id integer, + icon_name character varying, + github character varying, + slack character varying, + biography character varying, + pc_name character varying, + pc_os character varying, + pc_cpu character varying, + pc_ram character varying, + pc_storage character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + type_id integer +); +CREATE SEQUENCE public.user_details_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.user_details_id_seq OWNED BY public.user_details.id; +CREATE TABLE public.user_skills ( + id bigint NOT NULL, + user_id integer, + skill_id integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.user_skills_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.user_skills_id_seq OWNED BY public.user_skills.id; +CREATE TABLE public.users ( + id bigint NOT NULL, + provider character varying DEFAULT 'email'::character varying NOT NULL, + uid character varying DEFAULT ''::character varying NOT NULL, + encrypted_password character varying DEFAULT ''::character varying NOT NULL, + reset_password_token character varying, + reset_password_sent_at timestamp without time zone, + allow_password_change boolean DEFAULT false, + remember_created_at timestamp without time zone, + confirmation_token character varying, + confirmed_at timestamp without time zone, + confirmation_sent_at timestamp without time zone, + unconfirmed_email character varying, + name character varying, + email character varying, + tokens text, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); +CREATE SEQUENCE public.users_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; +ALTER TABLE ONLY public.bureaus ALTER COLUMN id SET DEFAULT nextval('public.bureaus_id_seq'::regclass); +ALTER TABLE ONLY public.categories ALTER COLUMN id SET DEFAULT nextval('public.categories_id_seq'::regclass); +ALTER TABLE ONLY public.chapters ALTER COLUMN id SET DEFAULT nextval('public.chapters_id_seq'::regclass); +ALTER TABLE ONLY public.curriculum_skills ALTER COLUMN id SET DEFAULT nextval('public.curriculum_skills_id_seq'::regclass); +ALTER TABLE ONLY public.curriculums ALTER COLUMN id SET DEFAULT nextval('public.curriculums_id_seq'::regclass); +ALTER TABLE ONLY public.departments ALTER COLUMN id SET DEFAULT nextval('public.departments_id_seq'::regclass); +ALTER TABLE ONLY public.grades ALTER COLUMN id SET DEFAULT nextval('public.grades_id_seq'::regclass); +ALTER TABLE ONLY public.project_skills ALTER COLUMN id SET DEFAULT nextval('public.project_skills_id_seq'::regclass); +ALTER TABLE ONLY public.project_users ALTER COLUMN id SET DEFAULT nextval('public.project_users_id_seq'::regclass); +ALTER TABLE ONLY public.projects ALTER COLUMN id SET DEFAULT nextval('public.projects_id_seq'::regclass); +ALTER TABLE ONLY public.records ALTER COLUMN id SET DEFAULT nextval('public.records_id_seq'::regclass); +ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass); +ALTER TABLE ONLY public.skills ALTER COLUMN id SET DEFAULT nextval('public.skills_id_seq'::regclass); +ALTER TABLE ONLY public.teachers ALTER COLUMN id SET DEFAULT nextval('public.teachers_id_seq'::regclass); +ALTER TABLE ONLY public.types ALTER COLUMN id SET DEFAULT nextval('public.types_id_seq'::regclass); +ALTER TABLE ONLY public.user_details ALTER COLUMN id SET DEFAULT nextval('public.user_details_id_seq'::regclass); +ALTER TABLE ONLY public.user_skills ALTER COLUMN id SET DEFAULT nextval('public.user_skills_id_seq'::regclass); +ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); +ALTER TABLE ONLY public.bureaus + ADD CONSTRAINT bureaus_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.categories + ADD CONSTRAINT categories_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.chapters + ADD CONSTRAINT chapters_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.curriculum_skills + ADD CONSTRAINT curriculum_skills_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.curriculums + ADD CONSTRAINT curriculums_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.departments + ADD CONSTRAINT departments_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.grades + ADD CONSTRAINT grades_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.project_skills + ADD CONSTRAINT project_skills_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.project_users + ADD CONSTRAINT project_users_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.projects + ADD CONSTRAINT projects_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.records + ADD CONSTRAINT records_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.roles + ADD CONSTRAINT roles_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.skills + ADD CONSTRAINT skills_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.teachers + ADD CONSTRAINT teachers_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.types + ADD CONSTRAINT types_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.user_details + ADD CONSTRAINT user_details_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.user_skills + ADD CONSTRAINT user_skills_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); +CREATE UNIQUE INDEX index_users_on_confirmation_token ON public.users USING btree (confirmation_token); +CREATE UNIQUE INDEX index_users_on_email ON public.users USING btree (email); +CREATE UNIQUE INDEX index_users_on_reset_password_token ON public.users USING btree (reset_password_token); +CREATE UNIQUE INDEX index_users_on_uid_and_provider ON public.users USING btree (uid, provider); From 6a97c41a09f5c1b0683e6e08010eed70006495a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Tue, 30 May 2023 03:12:49 +0900 Subject: [PATCH 5/8] [mod] hasura docker image (#196) --- .docker/hasura.Dockerfile | 3 ++- docker-compose.yml | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.docker/hasura.Dockerfile b/.docker/hasura.Dockerfile index 9ad685b..576085b 100644 --- a/.docker/hasura.Dockerfile +++ b/.docker/hasura.Dockerfile @@ -1,3 +1,4 @@ -FROM hasura/graphql-engine:latest +FROM hasura/graphql-engine:latest.cli-migrations-v3 WORKDIR /hasura RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash +RUN apt install postgresql-client \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6c3f489..07e72ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,11 @@ services: POSTGRES_USER: seeds POSTGRES_PASSWORD: password POSTGRES_HOST_AUTH_METHOD: trust + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 seeds_api: build: ./api @@ -33,10 +38,15 @@ services: volumes: - ./hasura:/hasura environment: + HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura/migrations + HASURA_GRAPHQL_METADATA_DIR: /hasura/metadata HASURA_GRAPHQL_ENABLE_CONSOLE: "true" HASURA_GRAPHQL_DATABASE_URL: postgres://seeds:password@seeds_db:5432/myapp_development HASURA_GRAPHQL_DEV_MODE: "true" HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log + depends_on: + seeds_db: + condition: service_healthy seeds_view: build: ./view From 415f69e0abbb8fdb644e69ea6a2a22f27161c5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Tue, 30 May 2023 03:13:02 +0900 Subject: [PATCH 6/8] [add] hasura make file (#196) --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 48f75fb..a13e601 100644 --- a/Makefile +++ b/Makefile @@ -17,3 +17,11 @@ db: docker compose run --rm seeds_api rails db:create docker compose run --rm seeds_api rails db:migrate docker compose run --rm seeds_api rails db:seed_fu + +db-export: + docker compose up hasura -d + sleep 15 + docker compose exec hasura hasura metadata export + docker compose exec hasura hasura migrate create "auto" --from-server --database-name default + docker compose exec hasura hasura migrate status --database-name default + docker compose down \ No newline at end of file From b3717cb2223b4cbd5fffbe25ca966a69b0dc723e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Fri, 2 Jun 2023 02:43:48 +0900 Subject: [PATCH 7/8] [mod] hasura relation (#196) --- docker-compose.yml | 2 +- .../default/tables/public_bureaus.yaml | 8 ++++ .../default/tables/public_categories.yaml | 8 ++++ .../default/tables/public_chapters.yaml | 12 +++++ .../tables/public_curriculum_skills.yaml | 7 +++ .../default/tables/public_curriculums.yaml | 19 ++++++++ .../default/tables/public_departments.yaml | 8 ++++ .../default/tables/public_grades.yaml | 8 ++++ .../default/tables/public_project_skills.yaml | 7 +++ .../default/tables/public_project_users.yaml | 10 +++++ .../default/tables/public_projects.yaml | 15 +++++++ .../default/tables/public_records.yaml | 15 +++++++ .../default/tables/public_roles.yaml | 8 ++++ .../default/tables/public_skills.yaml | 36 +++++++++++++++ .../default/tables/public_teachers.yaml | 7 +++ .../default/tables/public_types.yaml | 15 +++++++ .../default/tables/public_user_details.yaml | 16 +++++++ .../default/tables/public_user_skills.yaml | 7 +++ .../default/tables/public_users.yaml | 36 +++++++++++++++ .../default/1685636429787_auto/up.sql | 44 +++++++++++++++++++ 20 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 hasura/migrations/default/1685636429787_auto/up.sql diff --git a/docker-compose.yml b/docker-compose.yml index 07e72ed..834cfee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,7 @@ services: container_name: "seeds_hasura" ports: - "8082:8080" - restart: always + # restart: always volumes: - ./hasura:/hasura environment: diff --git a/hasura/metadata/databases/default/tables/public_bureaus.yaml b/hasura/metadata/databases/default/tables/public_bureaus.yaml index ea336b9..922dcb6 100644 --- a/hasura/metadata/databases/default/tables/public_bureaus.yaml +++ b/hasura/metadata/databases/default/tables/public_bureaus.yaml @@ -1,3 +1,11 @@ table: name: bureaus schema: public +array_relationships: + - name: user_details + using: + foreign_key_constraint_on: + column: bureau_id + table: + name: user_details + schema: public diff --git a/hasura/metadata/databases/default/tables/public_categories.yaml b/hasura/metadata/databases/default/tables/public_categories.yaml index 9b2afe9..659361e 100644 --- a/hasura/metadata/databases/default/tables/public_categories.yaml +++ b/hasura/metadata/databases/default/tables/public_categories.yaml @@ -1,3 +1,11 @@ table: name: categories schema: public +array_relationships: + - name: skills + using: + foreign_key_constraint_on: + column: category_id + table: + name: skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_chapters.yaml b/hasura/metadata/databases/default/tables/public_chapters.yaml index de6d082..7f0bf23 100644 --- a/hasura/metadata/databases/default/tables/public_chapters.yaml +++ b/hasura/metadata/databases/default/tables/public_chapters.yaml @@ -1,3 +1,15 @@ table: name: chapters schema: public +object_relationships: + - name: curriculum + using: + foreign_key_constraint_on: curriculum_id +array_relationships: + - name: records + using: + foreign_key_constraint_on: + column: chapter_id + table: + name: records + schema: public diff --git a/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml b/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml index 6ba5a84..36f86e8 100644 --- a/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml +++ b/hasura/metadata/databases/default/tables/public_curriculum_skills.yaml @@ -1,3 +1,10 @@ table: name: curriculum_skills schema: public +object_relationships: + - name: curriculum + using: + foreign_key_constraint_on: curriculum_id + - name: skill + using: + foreign_key_constraint_on: skill_id diff --git a/hasura/metadata/databases/default/tables/public_curriculums.yaml b/hasura/metadata/databases/default/tables/public_curriculums.yaml index 04ec991..8c02bc4 100644 --- a/hasura/metadata/databases/default/tables/public_curriculums.yaml +++ b/hasura/metadata/databases/default/tables/public_curriculums.yaml @@ -1,3 +1,22 @@ table: name: curriculums schema: public +object_relationships: + - name: skill + using: + foreign_key_constraint_on: skill_ids +array_relationships: + - name: chapters + using: + foreign_key_constraint_on: + column: curriculum_id + table: + name: chapters + schema: public + - name: curriculum_skills + using: + foreign_key_constraint_on: + column: curriculum_id + table: + name: curriculum_skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_departments.yaml b/hasura/metadata/databases/default/tables/public_departments.yaml index 12a7bdd..7abe85f 100644 --- a/hasura/metadata/databases/default/tables/public_departments.yaml +++ b/hasura/metadata/databases/default/tables/public_departments.yaml @@ -1,3 +1,11 @@ table: name: departments schema: public +array_relationships: + - name: user_details + using: + foreign_key_constraint_on: + column: department_id + table: + name: user_details + schema: public diff --git a/hasura/metadata/databases/default/tables/public_grades.yaml b/hasura/metadata/databases/default/tables/public_grades.yaml index 11c9b0e..d6c078d 100644 --- a/hasura/metadata/databases/default/tables/public_grades.yaml +++ b/hasura/metadata/databases/default/tables/public_grades.yaml @@ -1,3 +1,11 @@ table: name: grades schema: public +array_relationships: + - name: user_details + using: + foreign_key_constraint_on: + column: grade_id + table: + name: user_details + schema: public diff --git a/hasura/metadata/databases/default/tables/public_project_skills.yaml b/hasura/metadata/databases/default/tables/public_project_skills.yaml index 37db0b1..e656c5d 100644 --- a/hasura/metadata/databases/default/tables/public_project_skills.yaml +++ b/hasura/metadata/databases/default/tables/public_project_skills.yaml @@ -1,3 +1,10 @@ table: name: project_skills schema: public +object_relationships: + - name: project + using: + foreign_key_constraint_on: project_id + - name: skill + using: + foreign_key_constraint_on: skill_id diff --git a/hasura/metadata/databases/default/tables/public_project_users.yaml b/hasura/metadata/databases/default/tables/public_project_users.yaml index b26f1e2..c1045e5 100644 --- a/hasura/metadata/databases/default/tables/public_project_users.yaml +++ b/hasura/metadata/databases/default/tables/public_project_users.yaml @@ -1,3 +1,13 @@ table: name: project_users schema: public +object_relationships: + - name: project + using: + foreign_key_constraint_on: project_id + - name: role + using: + foreign_key_constraint_on: role_id + - name: user + using: + foreign_key_constraint_on: user_id diff --git a/hasura/metadata/databases/default/tables/public_projects.yaml b/hasura/metadata/databases/default/tables/public_projects.yaml index a1fcae4..f0f112e 100644 --- a/hasura/metadata/databases/default/tables/public_projects.yaml +++ b/hasura/metadata/databases/default/tables/public_projects.yaml @@ -1,3 +1,18 @@ table: name: projects schema: public +array_relationships: + - name: project_skills + using: + foreign_key_constraint_on: + column: project_id + table: + name: project_skills + schema: public + - name: project_users + using: + foreign_key_constraint_on: + column: project_id + table: + name: project_users + schema: public diff --git a/hasura/metadata/databases/default/tables/public_records.yaml b/hasura/metadata/databases/default/tables/public_records.yaml index 5c5285c..f331e8e 100644 --- a/hasura/metadata/databases/default/tables/public_records.yaml +++ b/hasura/metadata/databases/default/tables/public_records.yaml @@ -1,3 +1,18 @@ table: name: records schema: public +object_relationships: + - name: chapter + using: + foreign_key_constraint_on: chapter_id + - name: user + using: + foreign_key_constraint_on: user_id +array_relationships: + - name: teachers + using: + foreign_key_constraint_on: + column: record_id + table: + name: teachers + schema: public diff --git a/hasura/metadata/databases/default/tables/public_roles.yaml b/hasura/metadata/databases/default/tables/public_roles.yaml index c2e0c5b..ef92f67 100644 --- a/hasura/metadata/databases/default/tables/public_roles.yaml +++ b/hasura/metadata/databases/default/tables/public_roles.yaml @@ -1,3 +1,11 @@ table: name: roles schema: public +array_relationships: + - name: project_users + using: + foreign_key_constraint_on: + column: role_id + table: + name: project_users + schema: public diff --git a/hasura/metadata/databases/default/tables/public_skills.yaml b/hasura/metadata/databases/default/tables/public_skills.yaml index 92e08c9..8e7d1cd 100644 --- a/hasura/metadata/databases/default/tables/public_skills.yaml +++ b/hasura/metadata/databases/default/tables/public_skills.yaml @@ -1,3 +1,39 @@ table: name: skills schema: public +object_relationships: + - name: category + using: + foreign_key_constraint_on: category_id + - name: type + using: + foreign_key_constraint_on: type_id +array_relationships: + - name: curriculum_skills + using: + foreign_key_constraint_on: + column: skill_id + table: + name: curriculum_skills + schema: public + - name: curriculums + using: + foreign_key_constraint_on: + column: skill_ids + table: + name: curriculums + schema: public + - name: project_skills + using: + foreign_key_constraint_on: + column: skill_id + table: + name: project_skills + schema: public + - name: user_skills + using: + foreign_key_constraint_on: + column: skill_id + table: + name: user_skills + schema: public diff --git a/hasura/metadata/databases/default/tables/public_teachers.yaml b/hasura/metadata/databases/default/tables/public_teachers.yaml index b19c55a..12dc84f 100644 --- a/hasura/metadata/databases/default/tables/public_teachers.yaml +++ b/hasura/metadata/databases/default/tables/public_teachers.yaml @@ -1,3 +1,10 @@ table: name: teachers schema: public +object_relationships: + - name: record + using: + foreign_key_constraint_on: record_id + - name: user + using: + foreign_key_constraint_on: user_id diff --git a/hasura/metadata/databases/default/tables/public_types.yaml b/hasura/metadata/databases/default/tables/public_types.yaml index 6cab40e..bef7425 100644 --- a/hasura/metadata/databases/default/tables/public_types.yaml +++ b/hasura/metadata/databases/default/tables/public_types.yaml @@ -1,3 +1,18 @@ table: name: types schema: public +array_relationships: + - name: skills + using: + foreign_key_constraint_on: + column: type_id + table: + name: skills + schema: public + - name: user_details + using: + foreign_key_constraint_on: + column: type_id + table: + name: user_details + schema: public diff --git a/hasura/metadata/databases/default/tables/public_user_details.yaml b/hasura/metadata/databases/default/tables/public_user_details.yaml index 3f0f243..9564fa7 100644 --- a/hasura/metadata/databases/default/tables/public_user_details.yaml +++ b/hasura/metadata/databases/default/tables/public_user_details.yaml @@ -1,3 +1,19 @@ table: name: user_details schema: public +object_relationships: + - name: bureau + using: + foreign_key_constraint_on: bureau_id + - name: department + using: + foreign_key_constraint_on: department_id + - name: grade + using: + foreign_key_constraint_on: grade_id + - name: type + using: + foreign_key_constraint_on: type_id + - name: user + using: + foreign_key_constraint_on: user_id diff --git a/hasura/metadata/databases/default/tables/public_user_skills.yaml b/hasura/metadata/databases/default/tables/public_user_skills.yaml index db0987d..acc8197 100644 --- a/hasura/metadata/databases/default/tables/public_user_skills.yaml +++ b/hasura/metadata/databases/default/tables/public_user_skills.yaml @@ -1,3 +1,10 @@ table: name: user_skills schema: public +object_relationships: + - name: skill + using: + foreign_key_constraint_on: skill_id + - name: user + using: + foreign_key_constraint_on: user_id diff --git a/hasura/metadata/databases/default/tables/public_users.yaml b/hasura/metadata/databases/default/tables/public_users.yaml index 52de1e0..63266bb 100644 --- a/hasura/metadata/databases/default/tables/public_users.yaml +++ b/hasura/metadata/databases/default/tables/public_users.yaml @@ -1,3 +1,39 @@ table: name: users schema: public +array_relationships: + - name: project_users + using: + foreign_key_constraint_on: + column: user_id + table: + name: project_users + schema: public + - name: records + using: + foreign_key_constraint_on: + column: user_id + table: + name: records + schema: public + - name: teachers + using: + foreign_key_constraint_on: + column: user_id + table: + name: teachers + schema: public + - name: user_details + using: + foreign_key_constraint_on: + column: user_id + table: + name: user_details + schema: public + - name: user_skills + using: + foreign_key_constraint_on: + column: user_id + table: + name: user_skills + schema: public diff --git a/hasura/migrations/default/1685636429787_auto/up.sql b/hasura/migrations/default/1685636429787_auto/up.sql new file mode 100644 index 0000000..e930de9 --- /dev/null +++ b/hasura/migrations/default/1685636429787_auto/up.sql @@ -0,0 +1,44 @@ +ALTER TABLE ONLY public.chapters + ADD CONSTRAINT chapters_curriculum_id_fkey FOREIGN KEY (curriculum_id) REFERENCES public.curriculums(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.curriculum_skills + ADD CONSTRAINT curriculum_skills_curriculum_id_fkey FOREIGN KEY (curriculum_id) REFERENCES public.curriculums(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.curriculum_skills + ADD CONSTRAINT curriculum_skills_skill_id_fkey FOREIGN KEY (skill_id) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.curriculums + ADD CONSTRAINT curriculums_skill_ids_fkey FOREIGN KEY (skill_ids) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.project_skills + ADD CONSTRAINT project_skills_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.project_skills + ADD CONSTRAINT project_skills_skill_id_fkey FOREIGN KEY (skill_id) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.project_users + ADD CONSTRAINT project_users_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.project_users + ADD CONSTRAINT project_users_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.project_users + ADD CONSTRAINT project_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.records + ADD CONSTRAINT records_chapter_id_fkey FOREIGN KEY (chapter_id) REFERENCES public.chapters(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.records + ADD CONSTRAINT records_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.skills + ADD CONSTRAINT skills_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.categories(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.skills + ADD CONSTRAINT skills_type_id_fkey FOREIGN KEY (type_id) REFERENCES public.types(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.teachers + ADD CONSTRAINT teachers_record_id_fkey FOREIGN KEY (record_id) REFERENCES public.records(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.teachers + ADD CONSTRAINT teachers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_details + ADD CONSTRAINT user_details_bureau_id_fkey FOREIGN KEY (bureau_id) REFERENCES public.bureaus(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_details + ADD CONSTRAINT user_details_department_id_fkey FOREIGN KEY (department_id) REFERENCES public.departments(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_details + ADD CONSTRAINT user_details_grade_id_fkey FOREIGN KEY (grade_id) REFERENCES public.grades(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_details + ADD CONSTRAINT user_details_type_id_fkey FOREIGN KEY (type_id) REFERENCES public.types(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_details + ADD CONSTRAINT user_details_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_skills + ADD CONSTRAINT user_skills_skill_id_fkey FOREIGN KEY (skill_id) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +ALTER TABLE ONLY public.user_skills + ADD CONSTRAINT user_skills_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT; From 15e79861927b84d2243b6ed62a193ebf377f3f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E6=B5=A6=20=E7=BF=BC?= Date: Sat, 10 Jun 2023 00:50:36 +0900 Subject: [PATCH 8/8] Revert "[mod] change db mysql->postgres (#196)" --- api/Gemfile | 3 +-- api/Gemfile.lock | 4 ++-- api/config/database.yml | 7 ++++--- api/db/schema.rb | 39 ++++++++++++++++++--------------------- docker-compose.yml | 38 +++++++++++++++++++++++++++++++------- 5 files changed, 56 insertions(+), 35 deletions(-) diff --git a/api/Gemfile b/api/Gemfile index 14aa49b..d77f7f2 100644 --- a/api/Gemfile +++ b/api/Gemfile @@ -6,8 +6,7 @@ ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.3', '>= 6.1.3.1' # Use mysql as the database for Active Record -# gem 'mysql2', '~> 0.5' -gem 'pg', '~> 1.1' +gem 'mysql2', '~> 0.5' # Use Puma as the app server gem 'puma', '~> 5.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/api/Gemfile.lock b/api/Gemfile.lock index 3258458..029c76b 100644 --- a/api/Gemfile.lock +++ b/api/Gemfile.lock @@ -108,12 +108,12 @@ GEM mini_portile2 (2.6.1) minitest (5.14.4) msgpack (1.4.2) + mysql2 (0.5.3) nio4r (2.5.8) nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) orm_adapter (0.5.0) - pg (1.5.3) puma (5.5.2) nio4r (~> 2.0) racc (1.6.0) @@ -196,7 +196,7 @@ DEPENDENCIES devise_token_auth dotenv-rails listen (~> 3.3) - pg (~> 1.1) + mysql2 (~> 0.5) puma (~> 5.0) rack-cors rails (~> 6.1.3, >= 6.1.3.1) diff --git a/api/config/database.yml b/api/config/database.yml index d19f565..0e4286a 100644 --- a/api/config/database.yml +++ b/api/config/database.yml @@ -10,12 +10,13 @@ # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default - adapter: postgresql - encoding: unicode + adapter: mysql2 + encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: seeds + username: root password: password host: seeds_db + socket: /tmp/myapp.sock development: <<: *default diff --git a/api/db/schema.rb b/api/db/schema.rb index 3bc495f..f701595 100644 --- a/api/db/schema.rb +++ b/api/db/schema.rb @@ -12,23 +12,20 @@ ActiveRecord::Schema.define(version: 2023_02_21_091509) do - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" - - create_table "bureaus", force: :cascade do |t| + create_table "bureaus", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "categories", force: :cascade do |t| + create_table "categories", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "detail" end - create_table "chapters", force: :cascade do |t| + create_table "chapters", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "title" t.text "content" t.text "homework" @@ -38,14 +35,14 @@ t.integer "order" end - create_table "curriculum_skills", force: :cascade do |t| + create_table "curriculum_skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "curriculum_id" t.integer "skill_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "curriculums", force: :cascade do |t| + create_table "curriculums", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "title" t.integer "skill_ids" t.datetime "created_at", precision: 6, null: false @@ -53,26 +50,26 @@ t.text "graduation_assignment" end - create_table "departments", force: :cascade do |t| + create_table "departments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "grades", force: :cascade do |t| + create_table "grades", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "project_skills", force: :cascade do |t| + create_table "project_skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "project_id" t.integer "skill_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "project_users", force: :cascade do |t| + create_table "project_users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "project_id" t.integer "user_id" t.integer "role_id" @@ -80,7 +77,7 @@ t.datetime "updated_at", precision: 6, null: false end - create_table "projects", force: :cascade do |t| + create_table "projects", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.string "detail" t.string "icon_name" @@ -90,7 +87,7 @@ t.datetime "updated_at", precision: 6, null: false end - create_table "records", force: :cascade do |t| + create_table "records", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "title" t.text "content" t.text "homework" @@ -100,13 +97,13 @@ t.integer "chapter_id" end - create_table "roles", force: :cascade do |t| + create_table "roles", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "skills", force: :cascade do |t| + create_table "skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.string "detail" t.integer "category_id" @@ -115,20 +112,20 @@ t.integer "type_id" end - create_table "teachers", force: :cascade do |t| + create_table "teachers", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "user_id" t.integer "record_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "types", force: :cascade do |t| + create_table "types", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "user_details", force: :cascade do |t| + create_table "user_details", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "user_id" t.integer "grade_id" t.integer "department_id" @@ -147,14 +144,14 @@ t.integer "type_id" end - create_table "user_skills", force: :cascade do |t| + create_table "user_skills", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "user_id" t.integer "skill_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end - create_table "users", force: :cascade do |t| + create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "provider", default: "email", null: false t.string "uid", default: "", null: false t.string "encrypted_password", default: "", null: false diff --git a/docker-compose.yml b/docker-compose.yml index 834cfee..232bf03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,20 @@ version: "3" services: seeds_db: + image: mysql:8.0 + container_name: "seeds_db" + environment: + MYSQL_ROOT_PASSWORD: password + ports: + - "3306:3306" + command: --default-authentication-plugin=mysql_native_password + volumes: + - mysql-data:/var/lib/mysql + + seeds_hasura_db: image: postgres:12 volumes: - - mysql-data:/var/lib/postgresql/data + - db-data:/var/lib/postgresql/data environment: POSTGRES_DB: myapp_development POSTGRES_USER: seeds @@ -24,8 +35,9 @@ services: volumes: - ./api:/myapp depends_on: - seeds_db: - condition: service_started + - seeds_db + stdin_open: true + tty: true hasura: build: @@ -41,11 +53,11 @@ services: HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura/migrations HASURA_GRAPHQL_METADATA_DIR: /hasura/metadata HASURA_GRAPHQL_ENABLE_CONSOLE: "true" - HASURA_GRAPHQL_DATABASE_URL: postgres://seeds:password@seeds_db:5432/myapp_development + HASURA_GRAPHQL_DATABASE_URL: postgres://seeds:password@seeds_hasura_db:5432/myapp_development HASURA_GRAPHQL_DEV_MODE: "true" HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log depends_on: - seeds_db: + seeds_hasura_db: condition: service_healthy seeds_view: @@ -56,12 +68,24 @@ services: command: sh -c "npm install && npm run dev" volumes: - ./view:/app + stdin_open: true + tty: true environment: - SEEDS_API_URI=http://localhost:3000 + + # 定期実行用コンテナ + cron: + image: nutmeg-seeds-seeds_api:latest + command: > + sh -c "whenever --update-cron && + cron -f -l 2" + restart: always + volumes: + - ./api:/usr/src/app depends_on: - seeds_api: - condition: service_started + - seeds_api volumes: mysql-data: driver: local + db-data: