Skip to content

Filling the Database

Shomy edited this page Apr 9, 2024 · 13 revisions

⚠️ This is for seeding a development server with sample data. This cannot be used to make a copy of the Kitsu database

Get data into your development server

If you set up your development environment for the first time, bin/setup will offer you to do all of this automatically for you.
If you already have an environment set up, you can also use bin/seed to execute all of the steps described below.

bin/seed                       # All in one

bin/seed download              # Step 1
bin/seed import db             # Step 2
bin/seed reindex               # Step 3
bin/seed clean                 # Remove the downloaded db dump

  1. Download our media database dump (Dumped weekly)

  2. Import the dump to your database:

    gzcat latest.sql.gz | bin/psql kitsu_development
    
  3. Set up Elasticsearch:

    bin/rake chewy:reset
    

Starting with a blank database

Creating the database

Run the following to create the database and load structure.sql into it to get started:

$ bundle exec rake db:create db:structure:load

Gaining administrator access

Create an account with one of the staff emails. The confirmation email should be automatically opened in your default browser; if this fails, you can find it in tmp/letter_opener.

Filling the database

Go to /kotodama and enter id numbers from MyAnimeList into the "MAL Import" section to have them created automatically. Some of the ones with lots of characters and voice actors may time out: if this happens, you can use bundle exec rails console and run the following:

require 'mal_import'

Anime.create_or_update_from_hash MALImport.new(:anime, 123456).metadata

If you want to import Manga, replace all the "anime" with "manga" in that line.

Editing the database

Go to /kotodama/rails_admin. This will let you edit the database directly.