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
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 /docsearchFiles not uploading | Ente Help
Troubleshooting when files are not uploading from your Ente Photos app
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"}
Can you tell me what’s the value in schema_migrations table?
Where's that?
In the ente db?
Yes.
Output of this query:
-# If your issue is resolved, you can use the /solved command to close the thread. If not, use /unsolve to cancel.
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
Just run migrations/103_single_file_url.up.sql?
psql < /mnt/103_single_file_url.up.sql?Yes. Although you might see error if that migration queries failed in between.
Run the content of 103_single_file_url.down.sql first.
Now let's try to run the .up queries for 103
103_single_file_url.up.sql
Hm I did that
It errored here
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.
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.
It's possible podman is breaking this?
Sorry, but I am not sure if it's related podman. Haven't used it personally.
PS: Checking the stack trace.
Related to this trace: https://github.com/ente-io/ente/discussions/1474
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're using t...
Ayy that fixed it
Thank you
I should've searched this myself
Thank you
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.
To be fair I am running this in podman, so it's not properly setup with compose
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'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...
(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)
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
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
I just noticed my photos weren't loading and found this error too, it's the same for me.
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