简体   繁体   中英

TypeORM: Read Only Connection (Oracle)

I'm using TypeORM and I was wonderring if there's a way to prevent any edit to the database. I'm not totally sure if my entities will create or edit columns or tables in the database and I don't want that to happen like when setting relations between the tables, I don't want TypeORM to create a new foreign key if it does not exists.

I suppose you could create a DDL trigger that raises an exception.

create or replace trigger prevent_ddl_trg 
before ddl on schema
declare
begin
  raise_application_error(-20001, 'DDL not allowed')
end;

In 11.2 and higher, this seems to allow alters and drops on the trigger itself.

You can disable with:

alter trigger prevent_ddl_trg disable;

And enable with:

alter trigger prevent_ddl_trg enable;

Be careful with that though, you may prevent things you weren't expecting, like the ability to reset your own password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM