# How to use the database without destroying Discourse?

**URL:** https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695
**Category:** Development
**Created:** [9월 26, 2016, 11:31오후 UTC](https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695 "2016-09-26T23:31:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Silvanus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/silvanus/32/62831_2.png) [@Silvanus](https://meta.discourse.org/u/Silvanus)
#### Post date: [9월 26, 2016, 11:31오후 UTC](https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695/1 "2016-09-26T23:31:22Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [9월 28, 2016, 9:40오전 UTC](https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695/2 "2016-09-28T09:40:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [9월 28, 2016, 2:46오후 UTC](https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695/3 "2016-09-28T14:46:20Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Silvanus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/silvanus/32/62831_2.png) [@Silvanus](https://meta.discourse.org/u/Silvanus)
#### Post date: [9월 28, 2016, 3:19오후 UTC](https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695/4 "2016-09-28T15:19:54Z")

</div>

> [@Falco](#):
>
> Use the built-in PluginStore, save everything on first run, and then use it.

Where can I find more info on this?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [9월 28, 2016, 6:42오후 UTC](https://meta.discourse.org/t/how-to-use-the-database-without-destroying-discourse/50695/5 "2016-09-28T18:42:28Z")

</div>

See examples on the source code of some plugins:

- [discourse-user-notes/plugin.rb at main · discourse/discourse-user-notes · GitHub](https://github.com/discourse/discourse-staff-notes/blob/master/plugin.rb#L27)

- [discourse-canned-replies/plugin.rb at main · discourse/discourse-canned-replies · GitHub](https://github.com/discourse/discourse-canned-replies/blob/master/plugin.rb#L38)
