-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
279 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/bk-user/bkuser/apps/data_source/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 3.2.20 on 2023-08-07 03:28 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='DataSourcePlugin', | ||
fields=[ | ||
('id', models.CharField(max_length=128, primary_key=True, serialize=False, verbose_name='数据源插件唯一标识')), | ||
('name', models.CharField(max_length=128, unique=True, verbose_name='数据源插件名称')), | ||
('description', models.TextField(blank=True, default='', verbose_name='描述')), | ||
('logo', models.TextField(blank=True, default='', null=True, verbose_name='Logo')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='DataSource', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('name', models.CharField(max_length=128, unique=True, verbose_name='数据源名称')), | ||
('owner_tenant_id', models.CharField(db_index=True, max_length=64, verbose_name='归属租户')), | ||
('plugin_config', models.JSONField(default=dict, verbose_name='数据源插件配置')), | ||
('sync_config', models.JSONField(default=dict, verbose_name='数据源同步任务配置')), | ||
('field_mapping', models.JSONField(default=dict, verbose_name='用户字段映射')), | ||
('plugin', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='data_source.datasourceplugin')), | ||
], | ||
options={ | ||
'ordering': ['id'], | ||
}, | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
src/bk-user/bkuser/apps/data_source/migrations/0002_auto_20230807_1412.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 3.2.20 on 2023-08-07 06:12 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def forwards_func(apps, schema_editor): | ||
""" | ||
初始化本地数据源插件 | ||
""" | ||
DataSourcePlugin = apps.get_model("data_source", "DataSourcePlugin") | ||
# FIXME: 待数据源插件确定后,重新初始化,国际化,这里暂时不使用枚举等 | ||
if not DataSourcePlugin.objects.filter(id="local").exists(): | ||
DataSourcePlugin.objects.create( | ||
id="local", | ||
name="本地数据源", | ||
description="支持用户和部门的增删改查,以及用户的登录认证", | ||
) | ||
|
||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('data_source', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards_func) | ||
] |
113 changes: 113 additions & 0 deletions
113
src/bk-user/bkuser/apps/data_source_organization/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Generated by Django 3.2.20 on 2023-08-07 03:31 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import mptt.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='DataSourceDepartment', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('data_source_id', models.IntegerField(verbose_name='数据源 ID')), | ||
('code', models.CharField(blank=True, max_length=128, null=True, verbose_name='部门标识')), | ||
('name', models.CharField(max_length=255, verbose_name='部门名称')), | ||
('extras', models.JSONField(default=dict, verbose_name='自定义字段')), | ||
], | ||
options={ | ||
'ordering': ['id'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='DataSourceUser', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('data_source_id', models.IntegerField(verbose_name='数据源 ID')), | ||
('username', models.CharField(max_length=128, verbose_name='用户名')), | ||
('full_name', models.CharField(max_length=128, verbose_name='姓名')), | ||
('email', models.EmailField(blank=True, default='', max_length=254, null=True, verbose_name='邮箱')), | ||
('phone', models.CharField(max_length=32, verbose_name='手机号')), | ||
('phone_country_code', models.CharField(blank=True, default='86', max_length=16, null=True, verbose_name='手机国际区号')), | ||
('logo', models.TextField(blank=True, default='', max_length=256, null=True, verbose_name='Logo')), | ||
('extras', models.JSONField(default=dict, verbose_name='自定义字段')), | ||
], | ||
options={ | ||
'ordering': ['id'], | ||
'unique_together': {('username', 'data_source_id')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='DataSourceUserLeaderRelation', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user_id', models.IntegerField(db_index=True, verbose_name='数据源用户 ID')), | ||
('leader_id', models.IntegerField(db_index=True, verbose_name='数据源用户 Leader ID')), | ||
], | ||
options={ | ||
'ordering': ['id'], | ||
'unique_together': {('user_id', 'leader_id')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='DataSourceDepartmentUserRelation', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('department_id', models.IntegerField(db_index=True, verbose_name='数据源部门 ID')), | ||
('user_id', models.IntegerField(db_index=True, verbose_name='数据源用户 ID')), | ||
], | ||
options={ | ||
'ordering': ['id'], | ||
'unique_together': {('department_id', 'user_id')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='LocalDataSourceIdentityInfo', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('password', models.CharField(blank=True, default='', max_length=255, null=True, verbose_name='用户密码')), | ||
('password_updated_at', models.DateTimeField(blank=True, null=True, verbose_name='密码最后更新时间')), | ||
('password_expired_at', models.DateTimeField(blank=True, null=True, verbose_name='密码过期时间')), | ||
('data_source_id', models.IntegerField(verbose_name='数据源 ID')), | ||
('username', models.CharField(max_length=128, verbose_name='用户名')), | ||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='data_source_organization.datasourceuser')), | ||
], | ||
options={ | ||
'unique_together': {('username', 'data_source_id')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='DataSourceDepartmentRelation', | ||
fields=[ | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('id', models.IntegerField(primary_key=True, serialize=False, verbose_name='部门 ID')), | ||
('data_source_id', models.IntegerField(verbose_name='数据源 ID')), | ||
('lft', models.PositiveIntegerField(editable=False)), | ||
('rght', models.PositiveIntegerField(editable=False)), | ||
('tree_id', models.PositiveIntegerField(db_index=True, editable=False)), | ||
('level', models.PositiveIntegerField(editable=False)), | ||
('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='data_source_organization.datasourcedepartmentrelation')), | ||
], | ||
options={ | ||
'index_together': {('tree_id', 'lft', 'rght'), ('parent_id', 'tree_id', 'lft')}, | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 3.2.20 on 2023-08-07 03:28 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Tenant', | ||
fields=[ | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('id', models.CharField(max_length=128, primary_key=True, serialize=False, verbose_name='租户唯一标识')), | ||
('name', models.CharField(max_length=128, unique=True, verbose_name='租户名称')), | ||
('logo', models.TextField(blank=True, default='', null=True, verbose_name='Logo')), | ||
('is_default', models.BooleanField(default=False, verbose_name='是否默认租户')), | ||
('feature_flags', models.JSONField(default=dict, verbose_name='租户特性标志集')), | ||
], | ||
options={ | ||
'ordering': ['created_at'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='TenantManager', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('tenant_user_id', models.CharField(db_index=True, max_length=128, verbose_name='租户用户 ID')), | ||
('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tenant.tenant')), | ||
], | ||
options={ | ||
'unique_together': {('tenant', 'tenant_user_id')}, | ||
}, | ||
), | ||
] |
51 changes: 51 additions & 0 deletions
51
src/bk-user/bkuser/apps/tenant_organization/migrations/0001_initial.py
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters