Giter Site home page Giter Site logo

Database cleanup about hedgedoc HOT 3 CLOSED

hedgedoc avatar hedgedoc commented on May 11, 2024
Database cleanup

from hedgedoc.

Comments (3)

boschkundendienst avatar boschkundendienst commented on May 11, 2024 1

Today I tried it to fix it myself and it seemed it worked:

identify container id of postgres container

pgid=$(docker ps -a | grep postgres:9.6-alpine | awk '{print $1}')

start bash inside postgres container

docker exec -it $pgid /bin/bash
bash-4.4#

connect to database

bash-4.4# psql -d hackmd hackmd
psql (9.6.13)
Type "help" for help.

hackmd=#

find Notes that are empty and have no title

hackmd=# select id from public."Notes" where ((title = '') IS TRUE) AND ((content = '') IS TRUE);
                  id
--------------------------------------
 57670c01-7d4c-4bec-bb20-99d2b950f6e0
 a3b03a5d-c490-41ff-85f4-c8b58d2127a8
 887decc9-0230-40ca-9364-d96f273c1989
 964e41e3-12d4-4985-b4ca-2358e8b4f949
 f2dd2041-0b72-40ed-bd86-83e437d6557d
(5 rows)

delete above notes by id

hackmd=# delete from public."Notes" where id = '57670c01-7d4c-4bec-bb20-99d2b950f6e0';
DELETE 1
hackmd=# delete from public."Notes" where id = 'a3b03a5d-c490-41ff-85f4-c8b58d2127a8';
DELETE 1
hackmd=# delete from public."Notes" where id = '887decc9-0230-40ca-9364-d96f273c1989';
DELETE 1
hackmd=# delete from public."Notes" where id = '964e41e3-12d4-4985-b4ca-2358e8b4f949';
DELETE 1
hackmd=# delete from public."Notes" where id = 'f2dd2041-0b72-40ed-bd86-83e437d6557d';
DELETE 1

verify by exporting user data

From the CodiMD Web interface choose Export user data and download archive.zip. Open archive.zip with an unzip utility and verify that all markdown files have names based on their title. The files like

.md
-1.md
-2.md
-3.md
-4.md
-5.md

should be gone!

from hedgedoc.

ccoenen avatar ccoenen commented on May 11, 2024

These somehow made it into your database. I would guess that free url mode is configured, and that the missing images were requested by a browser, creating an empty document in the process. That document has no title or headline, so we have nothing to create a filename from.

So it's probably not directly caused by a crash.

from hedgedoc.

boschkundendienst avatar boschkundendienst commented on May 11, 2024

These somehow made it into your database. I would guess that free url mode is configured, and that the missing images were requested by a browser, creating an empty document in the process. That document has no title or headline, so we have nothing to create a filename from.

So it's probably not directly caused by a crash.

Ok. Is there a simple way for me to cleanup these strange documents. I think I would be able to connect into the postgres container and fire up some sql commands there. Any suggestions?

Thanks in advance

from hedgedoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.