Skip to main content
Level 3
Nov 20, 2025 5:39 PM UTC
Solved

Delete Schema via Javascript

Hi,

 

Is there a special method to delete schemas via javascript?

 

The following generates an error:

xtk.session.Write(<schema _operation="delete" xtkschema="xtk:sourceSchema" _key="@name" id={schemaName} />)

 

The error:

11/20/2025 12:29:20 PM XFR-180000 The file '/usr/local/neolane/nl6/datakit/xtk/eng/schema/sourceSchema.xml' does not exist on the server. Unable to load the document of identifier 'xtk:sourceSchema' and type 'xtk:schema'.

 

Thanks,

Skyler

ParthaSarathy
ParthaSarathyAccepted solution
Community Advisor
Nov 20, 2025 5:56 PM UTC

Hi @skylerqu2 ,

You can use SQL code activity and execute DROP TABLE customTable

or in JS, var sql = "DROP TABLE customTable"; xtk.session.executeQuery(sql);

But by both methods only tables will get deleted, but schema will still remain in the instance.

So, the best practice is instead of deleting using a script, navigate to Administration > Configuration > Data schemas and delete it and update the database structure.

 

~  ParthaSarathy S

3 replies

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
Nov 20, 2025 5:56 PM UTC

Hi @skylerqu2 ,

You can use SQL code activity and execute DROP TABLE customTable

or in JS, var sql = "DROP TABLE customTable"; xtk.session.executeQuery(sql);

But by both methods only tables will get deleted, but schema will still remain in the instance.

So, the best practice is instead of deleting using a script, navigate to Administration > Configuration > Data schemas and delete it and update the database structure.

 

Translate
~  ParthaSarathy S
SkylerQu2Author
Level 3
Nov 20, 2025 5:59 PM UTC

Hi @parthasarathy  thank you, yes, we are executing the DROP TABLE sql, but is there any way to remove the schema automatically?

Translate
ParthaSarathy
Community Advisor
Community Advisor
Nov 20, 2025 6:33 PM UTC

You can only manually delete from Administration > Configuration > Data schemas, thus you can also ensure there is no schema deleted by mistake and also can check if there is any relationship between other schema will get impacted. 

Translate
~  ParthaSarathy S