init commit,
This commit is contained in:
22
02_design/schema/modify_fake_table.js
Normal file
22
02_design/schema/modify_fake_table.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// process fake_auth.user to auth.user
|
||||
|
||||
// 1. open `schema.sql`
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
var schema = fs.readFileSync(path.join(__dirname, 'schema.sql'), 'utf8');
|
||||
|
||||
var schema_before = schema
|
||||
// 2. replace `CREATE TABLE "fake_auth.users" (*)` to ''
|
||||
schema = schema.replace(/CREATE TABLE "fake_auth"\."users" \(.*?\);/gs, '-- fake_auth.users part syntax removed.');
|
||||
if (schema.length == schema_before.length)
|
||||
console.log("cannot replace !!!")
|
||||
|
||||
schema_before = schema
|
||||
// 3. modify `REFERENCES "fake_auth.users"` to `REFERENCES "auth.users"`
|
||||
schema = schema.replace(/REFERENCES "fake_auth"\."users"/g, 'REFERENCES auth.users');
|
||||
if (schema.length == schema_before.length)
|
||||
console.log("cannot replace !!!")
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, 'schema.sql'), schema);
|
||||
|
||||
console.log("replace fake_auth.users to auth.users done . ")
|
Reference in New Issue
Block a user