# Troubles executing import/migration scripts

**URL:** <https://meta.discourse.org/t/troubles-executing-import-migration-scripts/240473>\
**Category:** Migration\
**Created:** [September 30, 2022, 10:24am UTC](https://meta.discourse.org/t/troubles-executing-import-migration-scripts/240473 "2022-09-30T10:24:04Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Maight723](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@Maight723](https://meta.discourse.org/u/Maight723)\
**Post date:** [September 30, 2022, 10:24am UTC](https://meta.discourse.org/t/troubles-executing-import-migration-scripts/240473/1 "2022-09-30T10:24:04Z")

</div>

I have successfully migrated a forum to Disourcse with a custom script before, but now when I execute it again, I get the following import error:

```plaintext
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client': We could not find your database: discourse. Which can be found in the database configuration file located at config/database.yml. (ActiveRecord::NoDatabaseError)

To resolve this issue:

- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.

To create your database, run:

        bin/rails db:create

```

The following import in my script fails:

```plaintext
require File.expand_path(File.dirname( __FILE__ ) + "/base.rb")

```

I execute the script with

```plaintext
./launcher enter app
cd /var/www/discourse
bundle exec ruby script/import_scripts/avatar.rb

```

I don’t really understand the error though: I can access the database through `sudo -u postgres psql discourse`, validating that the database “discourse” does exist. Also, the website is running fine. When I open `rails c` I can also access the data.

Can you give me some pointers what’s messed up there?

---

_[View the full topic](https://meta.discourse.org/t/troubles-executing-import-migration-scripts/240473)._
