You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 regels
530 B

  1. import webnotes
  2. # setup all tables for multi-tenant
  3. # ---------------------------------
  4. def setup_tables():
  5. import webnotes.multi_tenant
  6. tl = webnotes.conn.sql("show tables")
  7. for t in tl:
  8. add_tenant_id(t[0])
  9. change_primary_key(t[0])
  10. def add_tenant_id(tname):
  11. webnotes.conn.sql("alter table `%s` add column _tenant_id int(10) default 0 not null")
  12. def change_primary_key(tname):
  13. webnotes.conn.sql("alter table `%s` drop primary key name")
  14. webnotes.conn.sql("alter table `%s` add primary key (name, _tenant_id)")