studio icon indicating copy to clipboard operation
studio copied to clipboard

Support starting studio in read-only mode

Open midgleyc opened this issue 4 years ago • 11 comments

I'd like to use studio with a user which only has SELECT permissions, as a very good graphical tool for viewing databases with a web UI. Because of this permission structure, any calls to add a record or update fields will fail. Would it be possible to add an option to not show the "add record" button, or allow any fields to be changed?

A simple workaround is for me to tell anybody using this that trying to edit anything will fail, so they shouldn't try ;)

For more information around the use-case: I'm working with an old database that doesn't have e.g. cascaded updates, so any updates outside its management interface could possibly leave the database in an inconsistent state (leading to problems in other parts of the application). Because of this I'd like access outside the management interface to use a read-only user.

midgleyc avatar Feb 11 '21 13:02 midgleyc

Hi @midgleyc, thanks for this featre request! We will very likely build something like this very soon! We ourselves have a use case for this as well. Details are still hazy, but I'll keep you updated!

sdnts avatar Feb 12 '21 09:02 sdnts

Hey guys, Studio is a great tool to view your DB data. I like the simple nice UI, just feels great.

The only thing I am concern is about how fragile is, by easy way to edit/add/remove something. Like @midgleyc suggested, can we have a read-only view, so we can't break things in production just that easily?

The thing is I have a cat called Munja 🐱 which often likes to type random things on my mechanical keyboard, so I wanna prevent him from breaking my production app.

Jokes at the side, this would be a really useful feature.

Peace,

shtefcs avatar Apr 01 '21 13:04 shtefcs

I achieved this by having a read-only replica of the server. Now whenever I try to save anything to db from studio, it throws me a nice error. Although I had to migrate data fromnormal database to a master-slave database, which was a bit of pain for sure :D.

image

entrptaher avatar Apr 01 '21 16:04 entrptaher

Are there any updates on this request? Thanks!

Enigmaticall avatar Aug 11 '21 19:08 Enigmaticall

Hi @midgleyc, thanks for this featre request! We will very likely build something like this very soon! We ourselves have a use case for this as well. Details are still hazy, but I'll keep you updated!

Have you all been able to look into this further? We are in need of this functionality for our support team

Enigmaticall avatar Sep 10 '21 18:09 Enigmaticall

Hey, the Prisma Data Platform lets you do exactly that, have you given that a shot?

sdnts avatar Sep 14 '21 09:09 sdnts

I wonder if changing the .env for DATABASE_URL would work? Then you could flip back and forth. Would obviously require a read only user or read only follower.

virtualandy avatar Mar 22 '22 00:03 virtualandy

@sdnts any update to this? It's been years since last comment.

Am3ra avatar Feb 07 '24 19:02 Am3ra

Sorry about that, I don't work on Studio anymore, but @janpio should be able to speak to this.

sdnts avatar Feb 07 '24 21:02 sdnts

No concrete plans right now.

Besides using a read-only replica of your database as @entrptaher suggested, you could also create a database user that can only read data but not create, update or delete and use that in the connection string for Prisma Studio to achieve the same.

But I understand that built-in support would probably be nicer. How would you expect this to be selected or configured? CLI paramater --read-only or similar? Something else?

janpio avatar Jun 07 '24 13:06 janpio

@janpio I suggest reading from env variable, something like PRISMA_STUDIO_MODE="read" or so, then it can be overrided by a --mode="read" param from CLI, if none of them are present then go with default all mode, that way devs have a good level of flexibility and control.

hahouari avatar Jul 13 '24 14:07 hahouari