Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSTATE during migration #206

Closed
1 task done
macthecadillac opened this issue Feb 11, 2024 · 3 comments
Closed
1 task done

SQLSTATE during migration #206

macthecadillac opened this issue Feb 11, 2024 · 3 comments

Comments

@macthecadillac
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

2020_12_30_173528_add_owned_by_field_to_entities ................. 14ms FAIL

Illuminate\Database\QueryException

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'owned_by' (SQL: alter table pages add owned_by int unsigned not null)

at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
756▕ // If an exception occurs when attempting to run a query, we'll format the error
757▕ // message to include the bindings with SQL, which will make this exception a
758▕ // lot more helpful to the developer instead of just the database's errors.
759▕ catch (Exception $e) {
➜ 760▕ throw new QueryException(
761▕ $query, $this->prepareBindings($bindings), $e
762▕ );
763▕ }
764▕ }

  +9 vendor frames

10 /app/www/database/migrations/2020_12_30_173528_add_owned_by_field_to_entities.php:19
Illuminate\Support\Facades\Facade::__callStatic()

  +25 vendor frames

36 /app/www/artisan:35
Illuminate\Foundation\Console\Kernel::handle()

Expected Behavior

Successful Migration and application startup.

Steps To Reproduce

#!/bin/bash
podman pod create --hostname example.com --name bookstack-server

podman network create bookstack-net

podman run \
    --detach \
    --name mariadb \
    --pod bookstack-server \
    --label io.containers.autoupdate=registry \
    --label PODMAN_SYSTEMD_UNIT=mariadb.service \
    --network bookstack-net \
    --env MYSQL_DATABASE=bookstack \
    --env MYSQL_USER=bookstack \
    --env MYSQL_PASSWORD=db_pass \
    --env MYSQL_ROOT_PASSWORD=root_pw \
    --env TZ="US/Pacific" \
    --volume /home/bookstack/data/bookstack_db:/config:Z \
    lscr.io/linuxserver/mariadb:latest

podman run \
    --detach \
    --name bookstack \
    --pod bookstack-server \
    --label io.containers.autoupdate=registry \
    --label PODMAN_SYSTEMD_UNIT=bookstack.service \
    --network bookstack-net \
    --publish 6875:80 \
    --env APP_URL='https://example.com/bookstack' \
    --env DB_HOST=mariadb.dns.podman \
    --env DB_PORT=3306 \
    --env DB_USER=bookstack \
    --env DB_PASS=db_pass \
    --env DB_DATABASE=bookstack \
    --volume /home/bookstack/data/bookstack_app:/config:Z \
    lscr.io/linuxserver/bookstack:latest

Run the script. Error shows up in podman container logs bookstack

Environment

- OS: Debian GNU/Linux 12 (bookworm)
- How docker service was installed: sudo apt install podman

CPU architecture

x86-64

Docker creation

podman pod create --hostname example.com --name bookstack-server

podman network create bookstack-net

podman run \
    --detach \
    --name mariadb \
    --pod bookstack-server \
    --label io.containers.autoupdate=registry \
    --label PODMAN_SYSTEMD_UNIT=mariadb.service \
    --network bookstack-net \
    --env MYSQL_DATABASE=bookstack \
    --env MYSQL_USER=bookstack \
    --env MYSQL_PASSWORD=db_pass \
    --env MYSQL_ROOT_PASSWORD=root_pw \
    --env TZ="US/Pacific" \
    --volume /home/bookstack/data/bookstack_db:/config:Z \
    lscr.io/linuxserver/mariadb:latest

podman run \
    --detach \
    --name bookstack \
    --pod bookstack-server \
    --label io.containers.autoupdate=registry \
    --label PODMAN_SYSTEMD_UNIT=bookstack.service \
    --network bookstack-net \
    --publish 6875:80 \
    --env APP_URL='https://example.com/bookstack' \
    --env DB_HOST=mariadb.dns.podman \
    --env DB_PORT=3306 \
    --env DB_USER=bookstack \
    --env DB_PASS=db_pass \
    --env DB_DATABASE=bookstack \
    --volume /home/bookstack/data/bookstack_app:/config:Z \
    lscr.io/linuxserver/bookstack:latest

Container logs

[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    911
User GID:    911
───────────────────────────────────────

using keys found in /config/keys
App Key found - setting variable for seds
Running config - DB_HOST set
Waiting for DB to be available

   INFO  Running migrations.

  2020_12_30_173528_add_owned_by_field_to_entities ................. 14ms FAIL

   Illuminate\Database\QueryException

  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'owned_by' (SQL: alter table `pages` add `owned_by` int unsigned not null)

  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +9 vendor frames
  10  /app/www/database/migrations/2020_12_30_173528_add_owned_by_field_to_entities.php:19
      Illuminate\Support\Facades\Facade::__callStatic()

      +25 vendor frames
  36  /app/www/artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.
Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@ssddanbrown
Copy link
Contributor

Is this an upgrade of an old version? Or a new instance?
If a new instance, please delete your volume folder contents and re-create the containers from fresh data, then share the error you see on first run. The error you've shared above should only really occur on subsequent migration runs, not the first.

@macthecadillac
Copy link
Author

Thanks for the very prompt response and this fantastic piece of software.

It's a new instance, but yes the initial error was a bit different. I did a full system reset through podman system reset and deleted all the files in the volumes, it somehow fixed itself. I suppose the original problem I faced came from the --userns keep-id option, but once I removed that it was no longer an issue.

@LinuxServer-CI LinuxServer-CI moved this from Issues to Done in Issue & PR Tracker Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants