Yet another upgrade thread - I apologize…

Trying to upgrade my 0.12 instance on ubuntu. I wouldn’t mind going to 1.0.x first but couldn’t figure out a way to.

Anyway, I’m getting a connection to pgsql error running migrations.

My .env has this config:

I have a named database (redash012rc), and user:pwd.
I can connect to the database from a remote client so I’m guessing db connectivity is ok.

Any clues? Putting the error bellow.


arcims@vboxredash:~$ sudo ./
Starting Redash upgrade:
Found version: 2.0.0
Current version: 0.12.0+b2093

Full CHANGELOG for this release:
Continue with upgrade? (y/n): y
Downloading release tarball…
Unpacking to: redash.2.0.0.b2990…
Changing ownership to redash…
Linking .env file…
Installing new Python packages (if needed)…
Running migrations (if needed)…
Failed running: sudo -u redash bin/run ./ db upgrade
Exit status: 1
Traceback (most recent call last):
File “/opt/redash/redash.2.0.0.b2990/”, line 9, in
File “/usr/local/lib/python2.7/dist-packages/click/”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/flask/”, line 345, in main
return AppGroup.main(self, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/flask/”, line 229, in decorator
return __ctx.invoke(f, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/flask_migrate/”, line 132, in upgrade
_upgrade(directory, revision, sql, tag, x_arg)
File “/usr/local/lib/python2.7/dist-packages/flask_migrate/”, line 239, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File “/usr/local/lib/python2.7/dist-packages/alembic/”, line 254, in upgrade
File “/usr/local/lib/python2.7/dist-packages/alembic/script/”, line 425, in run_env
util.load_python_file(self.dir, ‘’)
File “/usr/local/lib/python2.7/dist-packages/alembic/util/”, line 81, in load_python_file
module = load_module_py(module_id, path)
File “/usr/local/lib/python2.7/dist-packages/alembic/util/”, line 141, in load_module_py
mod = imp.load_source(module_id, path, fp)
File “migrations/”, line 87, in
File “migrations/”, line 72, in run_migrations_online
connection = engine.connect()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 2082, in connect
return self._connection_cls(self, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 90, in init
if connection is not None else engine.raw_connection()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 2168, in raw_connection
self.pool.unique_connection, _connection)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 2142, in _wrap_pool_connect
e, dialect, self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 1456, in _handle_dbapi_exception_noconnection
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/”, line 202, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 2138, in _wrap_pool_connect
return fn()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 328, in unique_connection
return _ConnectionFairy._checkout(self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 766, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 516, in checkout
rec = pool._do_get()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 1229, in _do_get
return self._create_connection()
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 333, in _create_connection
return _ConnectionRecord(self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 461, in init
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/”, line 651, in __connect
connection = pool._invoke_creator(self)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 105, in connect
return dialect.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/”, line 392, in connect
return self.dbapi.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/dist-packages/psycopg2/”, line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

uau… stupid… turns out I had 3 slashes in my pgsql url… wrong. It should be:


For anyone this blind to know.

Was about to suggest checking this… Did it solve your issue?

Having a look now. Something must have gone wrong. I got the upgrade to succeed without errors, but all queries disappeared. When querying redash metada queries table I got:

Error running query: (psycopg2.ProgrammingError) column queries.version does not exist LINE 1: … AS queries_created_at, AS queries_id,… ^

Strange… it’s a vm I can rollback and try again…

Seems like one (or more) of the migrations wasn’t applied.

Can you think of a fast way to go to 1.0.x first?

Turns out it’s easy. Edit script upgrade, function get_release, just change this line from:
release = response.json()[0]

release = response.json()[2]

This will get v 1.0.1
Releases are:
0 = 2.0
1 = 1.0.3
2 = 1.0.1

I upgraded to 1.0.1 and got the same vanishing queries problem…

So I noticed my version is 0.12.0+b2093.

Not 0.12.0.b2449…


Looking at b2449 migrations I can see some I didn’t have.

How can I run migrations on 0.12? db does not exist yet…

When we upgraded to 2.0 which it looks like you are doing. We had to upgrade our Python packages as well. Also, we ended up blowing away our existing data connections and recreating them to Big Query. Then in Redash we had to touch all our queries to point to the newly creation BQ connection. Not sure if that is your issue here, but hopefully it helps.

@edowdy thanks but my problem seems to be missing columns, possibly I don’t have the final 0.12 db model.

@arikfr I tried running all migrations on 0.12 b2449 using the pre-1.0 command:
sudo -u redash PYTHONPATH=. bin/run python migrations/.py

But that got me a 500 error, regarding a template not found (index.html)…

I think I’ll have to install a fresh 0.12b2449 and manually retro fit the db model to my 0.12b2093. Then try to upgrade again.


Hmm… no differences in db between 0.12.0b2093 and 0.12.0b2449…

Last chance… try to upgrade to v2.0 and manually apply diff from 0.12 to 2.0 and see if it runs.

Are you running the migrations with a 0.12 codebase or from the v1/v2 codebase?

You should run them with a 0.12 codebase. Just fetch the tarball of the 0.12 version and run it from that directory. You better do this before upgrading the Python packages.

Yes I think I already did that. redash then complained with a 500 error before upgrading to 2.0.

Let me try again and I’ll let you know.

Thanks for replying.

Just to close this subject.

What I ended up doing is using pgdiff to get sql to migrate v0.12 to v2.0.
Run upgrade script just the 2 first steps: download and upgrade packages.
Run my sql script to effectively migrate the db.
Run upgrade script again but just the last 2 steps: point current to v2, and restart services.

I’ve tested v2 and seems ok. No errors for now. Going to look at logs just to be sure.


1 Like

:clap: glad you got it working.