go-shiori/shiori

Shiori can't migrate from 1.6.3 to last commit in master, if you use Postgres or Mariadb

Monirzadeh opened this issue · 4 comments

Data

  • Shiori version: last commit in master branch c107e97
  • Database Engine: postgress
  • Operating system: linux
  • CLI/Web interface/Web Extension: Web interface

Describe the bug / actual behavior

Shiori can't done migration from last release 1.6.3 to last we have in master (currently is commit c107e97) if you use postgres database and you will get this error

ERROR:  relation "shiori_system" does not exist at character 37

Expected behavior

Shiori can migrate without any error if you use Postgres

To Reproduce

Steps to reproduce the behavior:

  1. Get last Shiori release 1.6.3
  2. 
Run that with with a pg database with SHIORI_DATABASE_URL
  3. 
Shutdown Shiori

  4. Clone Shiori repository and try to setup same pg database with SHIORI_DATABASE_URL and run with go run main.go server

  5. As you see get bellow error in postgress log and Shiori not run
    ERROR: relation "shiori_system" does not exist at character 37

Notes

It not happen for Sqlite and happen in pg and mariadb

If my assumption is correct is weird that is not happening for SQLite, should happen for all engines. I will take a look at this later in the date or tomorrow, should be an easy fix.

Hey @Monirzadeh I can't replicate this. I create my PSQL database with 1.6.3, when I run the master branch I get the shiori_system database properly.

I got a different error though: #906

@fmartingr i test again. i have this in pg log

[postgres] | ERROR:  relation "shiori_system" does not exist at character 37
[postgres] | STATEMENT:  SELECT database_schema_version FROM shiori_system

and this in shiori log

WARN SHIORI_HTTP_SECRET_KEY is not set, using random value. This means that all sessions will be invalidated on server restart. 
error during commit: sql: transaction has already been committed or rolled back
error during commit: sql: transaction has already been committed or rolled back
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc5be91]

goroutine 1 [running]:
github.com/go-shiori/shiori/internal/database.init.func2(0xc000593450)
	/tmp/shiori/internal/database/pg.go:31 +0x111
github.com/go-shiori/shiori/internal/database.runMigrations({0x149ca18, 0x249e420}, {0x14a4cc0, 0xc00058ecf0}, {0x243c2c0, 0x3, 0x1c?})
	/tmp/shiori/internal/database/migrations.go:85 +0x31e
github.com/go-shiori/shiori/internal/database.(*PGDatabase).Migrate(0xc00041c220?, {0x149ca18?, 0x249e420?})
	/tmp/shiori/internal/database/pg.go:90 +0x46
github.com/go-shiori/shiori/internal/cmd.initShiori({0x149ca18, 0x249e420}, 0xc000174308)
	/tmp/shiori/internal/cmd/root.go:94 +0x60b
github.com/go-shiori/shiori/internal/cmd.newServerCommand.newServerCommandHandler.func1(0xc000174308, {0xf93dbe?, 0x4?, 0xf93d42?})
	/tmp/shiori/internal/cmd/server.go:50 +0x145
github.com/spf13/cobra.(*Command).execute(0xc000174308, {0x249e420, 0x0, 0x0})
	/home/myusername/.cache/go/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc000182308)
	/home/myusername/.cache/go/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x409f85?)
	/home/myusername/.cache/go/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x13
main.main()
	/tmp/shiori/main.go:26 +0x18
exit status 2

i remove time from logs

i test that on mariadb too and similar thing happen
mariadb log

[mariadb] | [Warning] Aborted connection 3 to db: 'shiori' user: 'shiori' host: '10.89.0.3' (Got an error reading communication packets)
[mariadb] | [Warning] Aborted connection 10 to db: 'shiori' user: 'shiori' host: '10.89.0.3' (Got an error reading communication packets)

shiori log

WARN SHIORI_HTTP_SECRET_KEY is not set, using random value. This means that all sessions will be invalidated on server restart. 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc5b8b1]

goroutine 1 [running]:
github.com/go-shiori/shiori/internal/database.init.func1(0xc0006c8750)
	/tmp/shiori/internal/database/mysql.go:35 +0x111
github.com/go-shiori/shiori/internal/database.runMigrations({0x149ca18, 0x249e420}, {0x14a4d60, 0xc0000c05a0}, {0x243d1c0, 0x7, 0x1c?})
	/tmp/shiori/internal/database/migrations.go:85 +0x31e
github.com/go-shiori/shiori/internal/database.(*MySQLDatabase).Migrate(0xc000042440?, {0x149ca18?, 0x249e420?})
	/tmp/shiori/internal/database/mysql.go:94 +0x46
github.com/go-shiori/shiori/internal/cmd.initShiori({0x149ca18, 0x249e420}, 0xc0006ca308)
	/tmp/shiori/internal/cmd/root.go:94 +0x60b
github.com/go-shiori/shiori/internal/cmd.newServerCommand.newServerCommandHandler.func1(0xc0006ca308, {0xf93dbe?, 0x4?, 0xf93d42?})
	/tmp/shiori/internal/cmd/server.go:50 +0x145
github.com/spf13/cobra.(*Command).execute(0xc0006ca308, {0x249e420, 0x0, 0x0})
	/home/myusername/.cache/go/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc00068c608)
	/home/myusername/.cache/go/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x409f85?)
	/home/myusername/.cache/go/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x13
main.main()
	/tmp/shiori/main.go:26 +0x18
exit status 2

i remove time from logs