Users are seeking ways to completely clear or reset their Discourse development databases to import new forum data. Silvanus initially tried various methods but encountered a migration error related to a missing groups.visible column after running rake db:drop db:create db:migrate. zogstrip suggested dropping and recreating the database, while pfaffman emphasized also removing uploads to avoid data leaks and shared a script for safely resetting the database. Silvanus confirmed uploads weren’t an issue since they only had a dump. gerhard offered a quick fix: running db:migrate twice. Pad_Pors asked about removing obsolete user fields still visible in profiles, linking to a related thread. 007 reported that the standard rake commands didn’t fully wipe data, prompting pgr to reference a thread on database ownership and wiping. pfaffman recommended backing up after initial setup and restoring it for quick resets. The thread reflects common challenges in development environments when preparing to re-import or reset Discourse instances.
So, I managed to import my age old forum into Discourse, and I madea Discourse backup of it. Later I will put it down in a production environment and make the static archive. Right now I’m on a developoment build. But now I’m running into a problem: I would like to clear out the database and insert my second forum into Discourse, so that the old forum is removed.
I tried a few threads below, but they didn’t give me the answer I need:
I once leaked a load of virus-infected uploads from one site I imported to another client.
Here is a gist of my new_discourse_database script that kills any running rubies (you can’t drop the database if rails s is running), deletes uploads, makes the new database, and sets an admin user and password. It also prints an obnoxious warning and waits 5 seconds since I’ve run it by mistake a few times too many.
After running bundle exec rake db:drop db:create db:migrate I get the following error:
== Seed from /home/jsilvanus/discourse/db/fixtures/500_lounge_category.rb
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column groups.visible does not exist
LINE 1: ...AS t1_r22, "groups"."visibility_level" AS t1_r23, "groups"."...
^
: SELECT "category_groups"."id" AS t0_r0, "category_groups"."category_id" AS t0_r1, "category_groups"."group_id" AS t0_r2, "category_groups"."created_at" AS t0_r3, "category_groups"."updated_at" AS t0_r4, "category_groups"."permission_type" AS t0_r5, "groups"."id" AS t1_r0, "groups"."name" AS t1_r1, "groups"."created_at" AS t1_r2, "groups"."updated_at" AS t1_r3, "groups"."automatic" AS t1_r4, "groups"."user_count" AS t1_r5, "groups"."alias_level" AS t1_r6, "groups"."automatic_membership_email_domains" AS t1_r7, "groups"."automatic_membership_retroactive" AS t1_r8, "groups"."primary_group" AS t1_r9, "groups"."title" AS t1_r10, "groups"."grant_trust_level" AS t1_r11, "groups"."incoming_email" AS t1_r12, "groups"."has_messages" AS t1_r13, "groups"."flair_url" AS t1_r14, "groups"."flair_bg_color" AS t1_r15, "groups"."flair_color" AS t1_r16, "groups"."bio_raw" AS t1_r17, "groups"."bio_cooked" AS t1_r18, "groups"."public" AS t1_r19, "groups"."allow_membership_requests" AS t1_r20, "groups"."full_name" AS t1_r21, "groups"."default_notification_level" AS t1_r22, "groups"."visibility_level" AS t1_r23, "groups"."visible" AS t1_r24 FROM "category_groups" INNER JOIN "groups" ON "groups"."id" = "category_groups"."group_id" WHERE "category_groups"."category_id" = 2 ORDER BY groups.name
/home/jsilvanus/discourse/app/serializers/category_serializer.rb:24:in `group_permissions'
/home/jsilvanus/discourse/app/serializers/category_serializer.rb:38:in `available_groups'
(eval):28:in `_fast_attributes'
/home/jsilvanus/discourse/app/models/category.rb:259:in `publish_category'
(eval):11:in `block (3 levels) in run_file'
(eval):9:in `block (2 levels) in run_file'
/home/jsilvanus/discourse/lib/tasks/db.rake:8:in `block in <main>'
/home/jsilvanus/.rbenv/versions/2.3.4/bin/bundle:23:in `load'
/home/jsilvanus/.rbenv/versions/2.3.4/bin/bundle:23:in `<main>'
PG::UndefinedColumn: ERROR: column groups.visible does not exist
LINE 1: ...AS t1_r22, "groups"."visibility_level" AS t1_r23, "groups"."...
^
/home/jsilvanus/discourse/app/serializers/category_serializer.rb:24:in `group_permissions'
/home/jsilvanus/discourse/app/serializers/category_serializer.rb:38:in `available_groups'
(eval):28:in `_fast_attributes'
/home/jsilvanus/discourse/app/models/category.rb:259:in `publish_category'
(eval):11:in `block (3 levels) in run_file'
(eval):9:in `block (2 levels) in run_file'
/home/jsilvanus/discourse/lib/tasks/db.rake:8:in `block in <main>'
/home/jsilvanus/.rbenv/versions/2.3.4/bin/bundle:23:in `load'
/home/jsilvanus/.rbenv/versions/2.3.4/bin/bundle:23:in `<main>'
NameError: NameError
/home/jsilvanus/discourse/app/models/category.rb:259:in `publish_category'
(eval):11:in `block (3 levels) in run_file'
(eval):9:in `block (2 levels) in run_file'
/home/jsilvanus/discourse/lib/tasks/db.rake:8:in `block in <main>'
/home/jsilvanus/.rbenv/versions/2.3.4/bin/bundle:23:in `load'
/home/jsilvanus/.rbenv/versions/2.3.4/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I ran db:drop and db:craete separately as well, they went fine. db:migrate gives the fail.
Hi, we had a user field which has been removed during time. but some users has already filled it. Is there anyway to remove or clear those entries from the database?
the reason I want to remove it, is that It’s annoying some of our old users, as they can’t change the field anymore.