Migration Failed

{"file":"main.go:899","func":"setupDatabase","level":"panic","msg":"migration failed: syntax error at or near "TRIGGER" (column 19) in line 23: \n\nCREATE TABLE IF NOT EXISTS public_file_tokens\n(\n id text primary key,\n file_id bigint NOT NULL,\n owner_id bigint NOT NULL,\n app text NOT NULL,\n access_token text not null,\n valid_till bigint not null DEFAULT 0,\n device_limit int not null DEFAULT 0,\n is_disabled bool not null DEFAULT FALSE,\n enable_download bool not null DEFAULT TRUE,\n pw_hash TEXT,\n pw_nonce TEXT,\n mem_limit BIGINT,\n ops_limit BIGINT,\n created_at bigint NOT NULL DEFAULT now_utc_micro_seconds(),\n updated_at bigint NOT NULL DEFAULT now_utc_micro_seconds()\n);\n\n\nCREATE OR REPLACE TRIGGER update_public_file_tokens_updated_at\n BEFORE UPDATE\n ON public_file_tokens\n FOR EACH ROW\nEXECUTE PROCEDURE\n trigger_updated_at_microseconds_column();\n\n\nCREATE TABLE IF NOT EXISTS public_file_tokens_access_history\n(\n id text NOT NULL,\n ip text not null,\n user_agent text not null,\n created_at bigint NOT NULL DEFAULT now_utc_micro_seconds(),\n CONSTRAINT unique_access_id_ip_ua UNIQUE (id, ip, user_agent),\n CONSTRAINT fk_public_file_history_token_id\n FOREIGN KEY (id)\n REFERENCES public_file_tokens (id)\n ON DELETE CASCADE\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS public_file_token_unique_idx ON public_file_tokens (access_token) WHERE is_disabled = FALSE;\nCREATE INDEX IF NOT EXISTS public_file_tokens_owner_id_updated_at_idx ON public_file_tokens (owner_id, updated_at);\nCREATE UNIQUE INDEX IF NOT EXISTS public_active_file_link_unique_idx ON public_file_tokens (file_id, is_disabled) WHERE is_disabled = FALSE;\n (details: pq: syntax error at or near "TRIGGER")","time":"2025-08-09T14:47:20Z"}
26 Replies
Ducky
Ducky3mo ago
The error message migration failed: syntax error at or near "TRIGGER" indicates a syntax error in your SQL statement during the database migration process. The error occurs in the CREATE OR REPLACE TRIGGER update_public_file_tokens_updated_at statement, specifically near the keyword "TRIGGER". You can see the full error message and the SQL script that caused it at https://help.ente.io/photos/troubleshooting/files-not-uploading#files-not-uploading. -# If your issue is resolved, feel free to use the /solved command to close this thread. If you'd like to ask me another question use /docsearch
Files not uploading | Ente Help
Troubleshooting when files are not uploading from your Ente Photos app
Dylanger
DylangerOP3mo ago
Migrated my postgresql server from 13 15 successfully However ente isn't running at all {"file":"main.go:107","func":"main","level":"info","msg":"Booting up local server with commit #2633ad62661f69bca7aded15addef147d6efad07","time":"2025-08-09T17:30:59Z"} {"file":"main.go:876","func":"setupDatabase","level":"info","msg":"Setting up db","time":"2025-08-09T17:30:59Z"} {"file":"main.go:883","func":"setupDatabase","level":"info","msg":"Connected to DB","time":"2025-08-09T17:30:59Z"} {"file":"main.go:888","func":"setupDatabase","level":"info","msg":"Pinged DB","time":"2025-08-09T17:30:59Z"} {"file":"main.go:897","func":"setupDatabase","level":"info","msg":"Loaded migration scripts","time":"2025-08-09T17:30:59Z"}
Neeraj
Neeraj3mo ago
Can you tell me what’s the value in schema_migrations table?
Dylanger
DylangerOP3mo ago
Where's that? In the ente db?
Neeraj
Neeraj3mo ago
Yes. Output of this query:
select * from schema_migrations;
select * from schema_migrations;
Dylanger
DylangerOP3mo ago
ente_db=# select * from schema_migrations;
version | dirty
---------+-------
103 | t
(1 row)
ente_db=# select * from schema_migrations;
version | dirty
---------+-------
103 | t
(1 row)
Ducky
Ducky3mo ago
-# If your issue is resolved, you can use the /solved command to close the thread. If not, use /unsolve to cancel.
Neeraj
Neeraj3mo ago
Okay. I am not sure they the migration 103 didn't work for you. We can either retry migration by first manually updating this table to: 102 version. Of you can just switch to 103 with dirty as false. But I would still suggest you to manually run the migration commands in migrations/103_single_file_url.up.sql
Dylanger
DylangerOP3mo ago
Just run migrations/103_single_file_url.up.sql? psql < /mnt/103_single_file_url.up.sql?
Neeraj
Neeraj3mo ago
Yes. Although you might see error if that migration queries failed in between. Run the content of 103_single_file_url.down.sql first.
DROP TABLE IF EXISTS public_file_tokens_access_history;
DROP TABLE IF EXISTS public_file_tokens;
DROP TABLE IF EXISTS public_file_tokens_access_history;
DROP TABLE IF EXISTS public_file_tokens;
Dylanger
DylangerOP3mo ago
postgres@c836f2d9b3f0:/$ psql < /var/lib/postgresql/data/103_single_file_url.down.sql
NOTICE: table "public_file_tokens_access_history" does not exist, skipping
DROP TABLE
NOTICE: table "public_file_tokens" does not exist, skipping
DROP TABLE
postgres@c836f2d9b3f0:/$ psql < /var/lib/postgresql/data/103_single_file_url.up.sql
ERROR: function now_utc_micro_seconds() does not exist
LINE 16: created_at bigint NOT NULL DEFAULT now_utc_micro_seco...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: relation "public_file_tokens" does not exist
ERROR: function now_utc_micro_seconds() does not exist
LINE 6: created_at bigint NOT NULL DEFAULT now_utc_micro_seconds...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: relation "public_file_tokens" does not exist
ERROR: relation "public_file_tokens" does not exist
ERROR: relation "public_file_tokens" does not exist
postgres@c836f2d9b3f0:/$ psql < /var/lib/postgresql/data/103_single_file_url.down.sql
NOTICE: table "public_file_tokens_access_history" does not exist, skipping
DROP TABLE
NOTICE: table "public_file_tokens" does not exist, skipping
DROP TABLE
postgres@c836f2d9b3f0:/$ psql < /var/lib/postgresql/data/103_single_file_url.up.sql
ERROR: function now_utc_micro_seconds() does not exist
LINE 16: created_at bigint NOT NULL DEFAULT now_utc_micro_seco...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: relation "public_file_tokens" does not exist
ERROR: function now_utc_micro_seconds() does not exist
LINE 6: created_at bigint NOT NULL DEFAULT now_utc_micro_seconds...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: relation "public_file_tokens" does not exist
ERROR: relation "public_file_tokens" does not exist
ERROR: relation "public_file_tokens" does not exist
Neeraj
Neeraj3mo ago
Now let's try to run the .up queries for 103 103_single_file_url.up.sql
Dylanger
DylangerOP3mo ago
Hm I did that It errored here
Neeraj
Neeraj3mo ago
This is fine. The error happened because public_file_tokens was not created. This is supposed to be created by 103_single_file_url.up.sql Just running following command should bring up the server.
update schema_migrations set version=103, dirty=false;
update schema_migrations set version=103, dirty=false;
The 103 migration is for an upcoming feature, it won't impact the current functioning of the app. However, after deploying the app, we would still want to ensure that all operations in 103_single_file_url.up.sql run successfully.
Dylanger
DylangerOP3mo ago
Aug 09 18:35:59 thirsty_hoover[24823]: panic: runtime error: invalid memory address or nil pointer dereference
Aug 09 18:35:59 thirsty_hoover[24823]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x10b9dba]
Aug 09 18:35:59 thirsty_hoover[24823]:
Aug 09 18:35:59 thirsty_hoover[24823]: goroutine 16 [running]:
Aug 09 18:35:59 thirsty_hoover[24823]: github.com/golang-migrate/migrate/v4.(*Migrate).lock.func3()
Aug 09 18:35:59 thirsty_hoover[24823]: /go/pkg/mod/github.com/golang-migrate/migrate/v4@v4.12.2/migrate.go:921 +0x1a
Aug 09 18:35:59 thirsty_hoover[24823]: created by github.com/golang-migrate/migrate/v4.(*Migrate).lock in goroutine 1
Aug 09 18:35:59 thirsty_hoover[24823]: /go/pkg/mod/github.com/golang-migrate/migrate/v4@v4.12.2/migrate.go:920 +0x1a8
Aug 09 18:35:59 podman[24840]: 2025-08-09 18:35:59.367838248 +0000 UTC m=+0.029995088 container died f94d03f7607a23b3689865fd75f630c2583a513723a65b673b192b1c54bc59d2 (image=localhost/ente:latest, name=thirsty_hoover, io.buildah.version=1.40.1, PODMAN_SYSTEMD_UNIT=museum.service)
Aug 09 18:35:59 podman[24840]: 2025-08-09 18:35:59.396542902 +0000 UTC m=+0.058699722 container remove f94d03f7607a23b3689865fd75f630c2583a513723a65b673b192b1c54bc59d2 (image=localhost/ente:latest, name=thirsty_hoover, PODMAN_SYSTEMD_UNIT=museum.service, io.buildah.version=1.40.1)
Aug 09 18:35:59 systemd[1270]: museum.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 09 18:35:59 systemd[1270]: museum.service: Failed with result 'exit-code'.
Aug 09 18:35:59 systemd[1270]: museum.service: Scheduled restart job, restart counter is at 5.
Aug 09 18:35:59 systemd[1270]: museum.service: Start request repeated too quickly.
Aug 09 18:35:59 systemd[1270]: museum.service: Failed with result 'exit-code'.
Aug 09 18:35:59 systemd[1270]: Failed to start museum.service - Podman container-relaxed_satoshi.service.
Aug 09 18:35:59 thirsty_hoover[24823]: panic: runtime error: invalid memory address or nil pointer dereference
Aug 09 18:35:59 thirsty_hoover[24823]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x10b9dba]
Aug 09 18:35:59 thirsty_hoover[24823]:
Aug 09 18:35:59 thirsty_hoover[24823]: goroutine 16 [running]:
Aug 09 18:35:59 thirsty_hoover[24823]: github.com/golang-migrate/migrate/v4.(*Migrate).lock.func3()
Aug 09 18:35:59 thirsty_hoover[24823]: /go/pkg/mod/github.com/golang-migrate/migrate/v4@v4.12.2/migrate.go:921 +0x1a
Aug 09 18:35:59 thirsty_hoover[24823]: created by github.com/golang-migrate/migrate/v4.(*Migrate).lock in goroutine 1
Aug 09 18:35:59 thirsty_hoover[24823]: /go/pkg/mod/github.com/golang-migrate/migrate/v4@v4.12.2/migrate.go:920 +0x1a8
Aug 09 18:35:59 podman[24840]: 2025-08-09 18:35:59.367838248 +0000 UTC m=+0.029995088 container died f94d03f7607a23b3689865fd75f630c2583a513723a65b673b192b1c54bc59d2 (image=localhost/ente:latest, name=thirsty_hoover, io.buildah.version=1.40.1, PODMAN_SYSTEMD_UNIT=museum.service)
Aug 09 18:35:59 podman[24840]: 2025-08-09 18:35:59.396542902 +0000 UTC m=+0.058699722 container remove f94d03f7607a23b3689865fd75f630c2583a513723a65b673b192b1c54bc59d2 (image=localhost/ente:latest, name=thirsty_hoover, PODMAN_SYSTEMD_UNIT=museum.service, io.buildah.version=1.40.1)
Aug 09 18:35:59 systemd[1270]: museum.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 09 18:35:59 systemd[1270]: museum.service: Failed with result 'exit-code'.
Aug 09 18:35:59 systemd[1270]: museum.service: Scheduled restart job, restart counter is at 5.
Aug 09 18:35:59 systemd[1270]: museum.service: Start request repeated too quickly.
Aug 09 18:35:59 systemd[1270]: museum.service: Failed with result 'exit-code'.
Aug 09 18:35:59 systemd[1270]: Failed to start museum.service - Podman container-relaxed_satoshi.service.
It's possible podman is breaking this?
Neeraj
Neeraj3mo ago
Sorry, but I am not sure if it's related podman. Haven't used it personally. PS: Checking the stack trace.
Neeraj
Neeraj3mo ago
GitHub
panic: runtime error: invalid memory address or nil pointer derefer...
Hi, me and a friend of mine are setting up local ente servers on our VPSs. I did it first and everything is working, while he cannot start museum with the following error message. We&#39;re using t...
Dylanger
DylangerOP3mo ago
Ayy that fixed it Thank you I should've searched this myself Thank you
Neeraj
Neeraj3mo ago
No worries. Happy that everything is fine. :pepepray: Ideally, the migration library should not have panicked. I am not sure if that is the expected behaviour. If more folks start running into this issue, we will spend time investigating this.
Dylanger
DylangerOP3mo ago
To be fair I am running this in podman, so it's not properly setup with compose
Manav
Manav3mo ago
About that, I was recently tinkering with Podman myself. Are there any tips you can give me? I have a feeling I'm "holding it wrong" sometimes, because I'm not fully familiar with Podman yet. My current notes are here - https://github.com/ente-io/ente/discussions/6800
GitHub
Ente meets Podman - A local development setup · ente-io ente · Di...
I&#39;ve been using Podman for my local containers recently, and I moved my local Ente development setup to use podman instead of Docker. Some notes of how I got it to work (stream of thought) in c...
Manav
Manav3mo ago
(you can add your tips on the thread itself, or here, which ever is more convenient. my aim is to eventually have first class support for Podman, though I don't know when I'll be able to get around to it. maybe I should put a partial podman json there, and then iterate with community help)
Dylanger
DylangerOP3mo ago
I'm not happy with my current setup, I'm currently using slirp4netns to provide connectivity between rootless containers, mainly for nginx - museum - postgres - minio, podman changed from slirp4netns to something better/newer. Lemme upgrade that and I'll add some tips, because it's kinda jank at the moment
Keerthana
Keerthana3mo ago
Alternately, you can write a community guide on this based on the GitHub discussions so that it's more helpful for others who wish to migrate to podman
Derb
Derb3mo ago
I just noticed my photos weren't loading and found this error too, it's the same for me.
Derb
Derb3mo ago
I'm running it in compose, not podman postgres:12 I got it to work by upgrading postgres and following the instructions in this thread, thanks

Did you find this page helpful?