The discussion revolves around database cleanup for testing an import script from OSQA to Discourse. praveendhinwa seeks a way to clear all data in a local Discourse instance to test the import script repeatedly. gerhard provides a solution using a series of commands to reset the development environment, including clearing uploads, logs, and temporary files, flushing Redis, and dropping and recreating the database. praveendhinwa confirms this works. RGJ shares a backup and restore method, which gerhard endorses, providing detailed bash scripts for backup and restore. freemangl encounters permission issues when running the commands in Docker, and gerhard clarifies that the scripts are not intended for Docker. freemangl asks for a Docker-compatible solution. muji786 inquires if praveendhinwa has completed the migration script and can share it.
I am trying to write an import script from OSQA to discourse. I have local Ubuntu installation of discourse. I wanted a way to know whether there is some cleanup script available which can delete all the data from all the tables of the discourse? Currently, when I run the script, the next time the entries already inserted are skipped.
If such a cleanup script was available, then I can experiment locally frequently, and it will help me essentially in writing such a script. If such a script is not available, then I guess my course is to just create stored function in PSQL.
Please guide me regarding this. I would be very thankful for this.
I always take a backup of an empty Discourse install with some tweaks made (admin user, allow_restore enabled, permalink settings, some adjusted limits to allow for a good import) and restore it when I want to start over again. Flushing redis is a good idea as well.
root@infdis-app:/var/www/discourse# bundle exec rake db:drop db:create db:migrate DISABLE_DATABASE_ENVIRONMENT_CHECK=1
===========================================
DEPRECATION: The cocaine gem is deprecated. Please upgrade to terrapin. See https://github.com/thoughtbot/terrapin/ for further instructions.
===========================================
PG::InsufficientPrivilege: ERROR: must be owner of database discourse
: DROP DATABASE IF EXISTS "discourse"
Couldn't drop database 'discourse'
rake aborted!
but after I su - discourse, I got another error:
discourse@infdis-app:/var/www/discourse$ bundle exec rake db:drop db:create db:migrate DISABLE_DATABASE_ENVIRONMENT_CHECK=1
===========================================
DEPRECATION: The cocaine gem is deprecated. Please upgrade to terrapin. See https://github.com/thoughtbot/terrapin/ for further instructions.
===========================================
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /var/www/discourse/tmp/ember-rails/ember.js