GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — automatic migrate support for containerized deploy · Issue #146 · sqlchat/sqlchat

automatic migrate support for containerized deploy #146

New issue
Copy link
New issue
Copy link
Open
Open
automatic migrate support for containerized deploy#146
Copy link
Labels
enhancementNew feature or requestNew feature or request

Description

@lushenle
lushenle
opened on Jan 29, 2024
Issue body actions

Is your feature request related to a problem?

The db schema is not initialized automatically after the service is started:

9d178106ae94:/# psql -U sqlchat_user -d sqlchat
psql (14.10)
Type "help" for help.

sqlchat=# \l
                                       List of databases
   Name    |    Owner     | Encoding |  Collate   |   Ctype    |       Access privileges
-----------+--------------+----------+------------+------------+-------------------------------
 postgres  | sqlchat_user | UTF8     | en_US.utf8 | en_US.utf8 |
 rbac_prod | sqlchat_user | UTF8     | en_US.utf8 | en_US.utf8 |
 sqlchat   | sqlchat_user | UTF8     | en_US.utf8 | en_US.utf8 |
 template0 | sqlchat_user | UTF8     | en_US.utf8 | en_US.utf8 | =c/sqlchat_user              +
           |              |          |            |            | sqlchat_user=CTc/sqlchat_user
 template1 | sqlchat_user | UTF8     | en_US.utf8 | en_US.utf8 | =c/sqlchat_user              +
           |              |          |            |            | sqlchat_user=CTc/sqlchat_user
(5 rows)

sqlchat=# \d
Did not find any relations.
sqlchat=# \dt
Did not find any relations.
sqlchat=#
...
postgres  | 2024-01-29 13:20:04.732 CST [22] LOG:  database system was shut down at 2024-01-29 13:15:06 CST
postgres  | 2024-01-29 13:20:04.742 CST [1] LOG:  database system is ready to accept connections
postgres  | 2024-01-29 13:37:14.614 CST [1458] ERROR:  relation "sqlchat.users" does not exist at character 215
postgres  | 2024-01-29 13:37:14.614 CST [1458] STATEMENT:  SELECT "sqlchat"."users"."id", "sqlchat"."users"."name", "sqlchat"."users"."email", "sqlchat"."users"."email_verified", "sqlchat"."users"."image", "sqlchat"."users"."stripe_id", "sqlchat"."users"."created_at" FROM "sqlchat"."users" WHERE ("sqlchat"."users"."email" = $1 AND 1=1) LIMIT $2 OFFSET $3

and also need to connect to the database externally, and then manually execute the migration

➜  sqlchat git:(feat-add-org-header) ✗ pnpm prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "sqlchat", schema "sqlchat" at "127.0.0.1:5432"

Applying migration `20230502100414_init`
Applying migration `20230505101306_account_and_payment`
Applying migration `20230517161946_subscription`
Applying migration `20230518165639_created_at_to_users_table`
Applying migration `20230521103659_separate_payment_from_subscription`
Applying migration `20230521112004_remove_subscription_status_add_cancel_at`

The following migration(s) have been applied:

migrations/
  └─ 20230502100414_init/
    └─ migration.sql
  └─ 20230505101306_account_and_payment/
    └─ migration.sql
  └─ 20230517161946_subscription/
    └─ migration.sql
  └─ 20230518165639_created_at_to_users_table/
    └─ migration.sql
  └─ 20230521103659_separate_payment_from_subscription/
    └─ migration.sql
  └─ 20230521112004_remove_subscription_status_add_cancel_at/
    └─ migration.sql

Your database is now in sync with your schema.

Describe the solution you'd like

adding automatic execution of database migrate when NEXT_PUBLIC_USE_DATABASE is set.

Additional context

No response

Activity

  1. lushenle
    added
    enhancementNew feature or requestNew feature or request
    on Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.