How to use the database without destroying Discourse?

I’m thinking of starting to make a plugin (working title: bookquote) that would replace citations from database and replace the citation in the message, for example [us-constitution 1.1] would give out All legislative Powers herein granted shall be vested in a Congress of the United States, which shall consist of a Senate and House of Representatives. (U.S. Constitution, I.1).

I’m not really a coder, I’m a humanist scholar myself, but I have some rudimentary knowledge of coding, postgresql, git, and I’m a really good in copy&paste. Nerd youth…

My first question is: can I use the same database that Discourse uses to store the data, or should I use some other kind of storage i.e. a file? If I can use the database, how do I do that so that I don’t destroy anything that Discourse is trying to do?

1 Like

Since you’ll be replacing the content of the posts, you don’t need a new storage area :wink:

I think he’s talking about where to put the constitution. You can either:

  • Put it in another database, and handle creating the connection, etc.

  • Use the built-in PluginStore, save everything on first run, and then use it.

Please don’t create a table inside Discourse database/schema. Your backups will be screwed.

4 Likes

Where can I find more info on this?

1 Like

See examples on the source code of some plugins:

4 Likes