I am trying to find the correct (any) method to create an application in **Ruby on Rails** having an existing database (**PostgreSQL**) with data and fresh app made with:

```sh
rails new --database=postgresql -J --skip-coffee .

```

I found <https://github.com/frenesim/schema_to_scaffold> but first I need to have a file with a database structure: `schema.rb`. I’m looking for a way to do it automatically. 

In result of `rake db:schema:dump`file `schema.rb` is generated, but only with content like that:

```rb
ActiveRecord::Schema.define(version: 0) do
  enable_extension "plpgsql"
end

```

And I stuck here. Why that file is empty? Why are there no tables here?

I have a connection with DB and no errors. I did `rake db:create` before to test. Creation of bases described in `database.yml` is successful.

At the beginning I used Docker containers and this is my goal. But to exclude the probability of error, I installed the environment in the system (macOS Mojave) based on the **socket**. And I’ve got the same effect.

How to generate `schema.rb` with structure of existing database? Or is there different way to build RoR app based on the existing data structure?

---

**Update**: Connection with the new database I only did for testing purposes. To verify configuration.

Here's what else I did:

1. Dump existing structure with  

`pg_dump --schema-only app_development > db/structure.sql`
2. I changed name in `database.yml` to have fresh place to import.
3. `rake db:setup` created new DB
4. `rake db:structure:load` create tables from `db/structure.sql` file in DB correctly.

But `rake db:schema:dump` still generate empty file as earlier.