[GH-ISSUE #391] npx @better-auth/cli generate stuck on "preparing schema..." #25571

Closed
opened 2026-04-17 15:50:50 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @MrKepzie on GitHub (Nov 2, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/391

Describe the bug

Whenever I run npx @better-auth/cli generate it is stuck on "preparing schema..." forever.

To Reproduce

I created a mysql database using a local docker compose file:

services:
    mysql:
        image: 'mysql/mysql-server:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: #
            MYSQL_ROOT_HOST: '%'
            MYSQL_DATABASE: betterauth
            MYSQL_USER: #
            MYSQL_PASSWORD: #
            #MYSQL_ALLOW_EMPTY_PASSWORD: 1
        volumes:
            - 'mysql-storage:/var/lib/mysql'
        networks:
            - astrolocal
        healthcheck:
            test:
                - CMD
                - mysqladmin
                - ping
                - '-p#'
            retries: 3
            timeout: 5s
    myadmin:
        image: phpmyadmin/phpmyadmin
        environment:
            - PMA_HOSTS=mysql
        ports:
            - "8090:80"
        depends_on:
            - mysql
        networks:
            - astrolocal
networks:
    astrolocal:
        driver: bridge
volumes:
    mysql-storage:
        driver: local

I then followed the documentation and created a src/auth.ts file :

import { betterAuth } from "better-auth";
import { createPool } from "mysql2/promise"

export const auth = betterAuth({
    database: createPool({
        host            : import.meta.env.ASTRO_DB_HOST,
        user            : import.meta.env.ASTRO_DB_USER,
        password        : import.meta.env.ASTRO_DB_PWD,
        database        : import.meta.env.ASTRO_DB_NAME
    }),
    emailAndPassword: {
		enabled: true,
	},
})

The environment variables are set in my .env file and matching what is set in the docker compose file.
Is this an issue with the mysql database ?

Did the setup with a postgres db and everything went fine.

Expected behavior

The schema should be generated

Desktop:

  • macOS, node.js 21.7.3
Originally created by @MrKepzie on GitHub (Nov 2, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/391 **Describe the bug** Whenever I run `npx @better-auth/cli generate` it is stuck on "preparing schema..." forever. **To Reproduce** I created a mysql database using a local docker compose file: ``` services: mysql: image: 'mysql/mysql-server:8.0' ports: - '${FORWARD_DB_PORT:-3306}:3306' environment: MYSQL_ROOT_PASSWORD: # MYSQL_ROOT_HOST: '%' MYSQL_DATABASE: betterauth MYSQL_USER: # MYSQL_PASSWORD: # #MYSQL_ALLOW_EMPTY_PASSWORD: 1 volumes: - 'mysql-storage:/var/lib/mysql' networks: - astrolocal healthcheck: test: - CMD - mysqladmin - ping - '-p#' retries: 3 timeout: 5s myadmin: image: phpmyadmin/phpmyadmin environment: - PMA_HOSTS=mysql ports: - "8090:80" depends_on: - mysql networks: - astrolocal networks: astrolocal: driver: bridge volumes: mysql-storage: driver: local ``` I then followed the documentation and created a src/auth.ts file : ``` import { betterAuth } from "better-auth"; import { createPool } from "mysql2/promise" export const auth = betterAuth({ database: createPool({ host : import.meta.env.ASTRO_DB_HOST, user : import.meta.env.ASTRO_DB_USER, password : import.meta.env.ASTRO_DB_PWD, database : import.meta.env.ASTRO_DB_NAME }), emailAndPassword: { enabled: true, }, }) ``` The environment variables are set in my `.env` file and matching what is set in the docker compose file. Is this an issue with the mysql database ? Did the setup with a postgres db and everything went fine. **Expected behavior** The schema should be generated **Desktop:** - macOS, node.js 21.7.3
GiteaMirror added the locked label 2026-04-17 15:50:50 -05:00
Author
Owner

@Bekacru commented on GitHub (Nov 2, 2024):

does the migrate command works?

<!-- gh-comment-id:2452936330 --> @Bekacru commented on GitHub (Nov 2, 2024): does the `migrate` command works?
Author
Owner

@MrKepzie commented on GitHub (Nov 2, 2024):

For what I recall it did not. I'm now using a postgres DB as it seems to work this way

<!-- gh-comment-id:2452945747 --> @MrKepzie commented on GitHub (Nov 2, 2024): For what I recall it did not. I'm now using a postgres DB as it seems to work this way
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#25571