Skip to content

DB (Postgres) - ERROR: relation "workspaces" does not exist #20649

@ozltr

Description

@ozltr

Steps to reproduce

How'd you do it?

Arch Linux

  1. sudo pacman -S metasploit , just installs metasploit
  2. cd /opt/metasploit
  3. gem install bundler
  4. bundle install -> bundle complete, 19 gemfile dependencies
  5. docker run postgres, docker run --name some-postgres -e POSTGRES_PASSWORD=postgres -d postgres
  6. msfdb init --connection-string="postgresql://postgres:[email protected]:5432/postgres"
  7. Database initialization successful
  8. msfconsole -y ~/.msf4/database.yaml
  9. terminal error:
/opt/metasploit/vendor/bundle/ruby/3.4.0/gems/activerecord-7.2.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in 'PG::Connection#exec': PG::UndefinedTable: ERROR:  relation "workspaces" does not exist (ActiveRecord::StatementInvalid)
LINE 10:  WHERE a.attrelid = '"workspaces"'::regclass
  1. postgres error:
2025-10-24 08:39:22.431 UTC [72] ERROR:  permission denied for schema public at character 14
2025-10-24 08:39:22.431 UTC [72] STATEMENT:  CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
2025-10-24 08:39:22.442 UTC [72] ERROR:  relation "workspaces" does not exist at character 523
2025-10-24 08:39:22.442 UTC [72] STATEMENT:  SELECT a.attname, format_type(a.atttypid, a.atttypmod),
	       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
	       c.collname, col_description(a.attrelid, a.attnum) AS comment,
	       attidentity AS identity,
	       attgenerated as attgenerated
	  FROM pg_attribute a
	  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
	  LEFT JOIN pg_type t ON a.atttypid = t.oid
	  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
	 WHERE a.attrelid = '"workspaces"'::regclass
	   AND a.attnum > 0 AND NOT a.attisdropped
	 ORDER BY a.attnum
	
  1. I logged into the postgres to check the table
msf=> SELECT attrelid
msf-> FROM pg_attribute
msf-> WHERE attrelid = "workspace";
ERROR:  column "workspace" does not exist
LINE 3: WHERE attrelid = "workspace";

Were you following a specific guide/tutorial or reading documentation?

If yes link the guide/tutorial or documentation you were following here, otherwise you may omit this section.

Expected behavior

Get into the msfconsole

Current behavior

Error occurs on startup

Metasploit version

Get this with the version command in msfconsole (or git log -1 --pretty=oneline for a source install).

Framework Version: 6.4.92-dev

Additional Information

Deleted the text here per the issue instructions

I think there is something in the ruby code where the workspace-field should actually become an integer, but it isn't. Because the whole sql table column is only integers. I don't know ruby unfortunately, otherwise I would've digged into the source.

Have a great day and thank you for reading my post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions