Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ca06063c
authored
Jan 25, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: Update down_revision in migration file to maintain proper versioning
1 parent
ac47be27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
425 additions
and
1 deletions
opensipkd/base/alembic/versions/021a8a342d5b_init_db.py
opensipkd/base/alembic/versions/10a68b1510a6_.py
opensipkd/base/alembic/versions/021a8a342d5b_init_db.py
0 → 100644
View file @
ca06063
"""Init db
Revision ID: 021a8a342d5b
Revises:
Create Date: 2026-01-25 11:30:47.960798
"""
# revision identifiers, used by Alembic.
revision
=
'021a8a342d5b'
down_revision
=
None
branch_labels
=
None
depends_on
=
None
from
alembic
import
op
import
sqlalchemy
as
sa
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
create_table
(
'groups'
,
sa
.
Column
(
'member_count'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'group_name'
,
sa
.
Unicode
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'description'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_groups'
)),
sa
.
UniqueConstraint
(
'group_name'
,
name
=
op
.
f
(
'uq_groups_group_name'
)),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'holiday'
,
sa
.
Column
(
'tanggal'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_holiday'
))
)
op
.
create_table
(
'logs'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'line_id'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'logger'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'level'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'trace'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'msg'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'created_at'
,
sa
.
DateTime
(
timezone
=
True
),
server_default
=
sa
.
text
(
'now()'
),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_logs'
)),
sa
.
UniqueConstraint
(
'line_id'
,
name
=
op
.
f
(
'uq_logs_line_id'
))
)
op
.
create_table
(
'parameters'
,
sa
.
Column
(
'value'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_parameters'
))
)
op
.
create_table
(
'departemen'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'parent_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'alamat'
,
sa
.
String
(
length
=
255
),
nullable
=
True
),
sa
.
Column
(
'singkat'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'level_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
ForeignKeyConstraint
([
'parent_id'
],
[
'public.departemen.id'
],
name
=
op
.
f
(
'fk_departemen_parent_id_departemen'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_departemen'
)),
schema
=
'public'
)
op
.
create_table
(
'permissions'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
String
(
length
=
64
),
nullable
=
False
),
sa
.
Column
(
'description'
,
sa
.
String
(
length
=
64
),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_permissions'
)),
sa
.
UniqueConstraint
(
'description'
,
name
=
op
.
f
(
'uq_permissions_description'
)),
sa
.
UniqueConstraint
(
'perm_name'
,
name
=
op
.
f
(
'uq_permissions_perm_name'
)),
schema
=
'public'
)
op
.
create_table
(
'res_provinsi'
,
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_provinsi'
)),
schema
=
'public'
)
op
.
create_table
(
'routes'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'path'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
Integer
(),
server_default
=
'1'
,
nullable
=
False
),
sa
.
Column
(
'type'
,
sa
.
SmallInteger
(),
server_default
=
'0'
,
nullable
=
False
),
sa
.
Column
(
'app_id'
,
sa
.
SmallInteger
(),
server_default
=
'0'
,
nullable
=
False
),
sa
.
Column
(
'module'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'is_menu'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'parent_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'order_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'permission'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'class_view'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'def_func'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'template'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'icon'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
ForeignKeyConstraint
([
'parent_id'
],
[
'routes.id'
],
name
=
op
.
f
(
'fk_routes_parent_id_routes'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_routes'
)),
sa
.
UniqueConstraint
(
'kode'
,
name
=
op
.
f
(
'uq_routes_kode'
)),
sa
.
UniqueConstraint
(
'path'
,
name
=
op
.
f
(
'uq_routes_path'
))
)
op
.
create_table
(
'target_jenis'
,
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_target_jenis'
))
)
op
.
create_table
(
'targets'
,
sa
.
Column
(
'tahun'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'jenis'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'm01'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm02'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm03'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm04'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm05'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm06'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm07'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm08'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm09'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm10'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm11'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'm12'
,
sa
.
BigInteger
(),
nullable
=
False
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_targets'
))
)
op
.
create_table
(
'users'
,
sa
.
Column
(
'last_login_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
True
),
sa
.
Column
(
'registered_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
False
),
sa
.
Column
(
'security_code_date'
,
sa
.
DateTime
(
timezone
=
True
),
server_default
=
'2000-01-01 01:01+7'
,
nullable
=
True
),
sa
.
Column
(
'api_key'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'partner_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'company_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
autoincrement
=
True
,
nullable
=
False
),
sa
.
Column
(
'user_name'
,
sa
.
Unicode
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'user_password'
,
sa
.
Unicode
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'email'
,
sa
.
Unicode
(
length
=
100
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'security_code'
,
sa
.
Unicode
(
length
=
256
),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_users'
)),
sa
.
UniqueConstraint
(
'email'
,
name
=
op
.
f
(
'uq_users_email'
)),
sa
.
UniqueConstraint
(
'user_name'
,
name
=
op
.
f
(
'uq_users_user_name'
)),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'external_identities'
,
sa
.
Column
(
'external_id'
,
sa
.
Unicode
(
length
=
255
),
nullable
=
False
),
sa
.
Column
(
'external_user_name'
,
sa
.
Unicode
(
length
=
255
),
nullable
=
True
),
sa
.
Column
(
'local_user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'provider_name'
,
sa
.
Unicode
(
length
=
50
),
nullable
=
False
),
sa
.
Column
(
'access_token'
,
sa
.
Unicode
(
length
=
512
),
nullable
=
True
),
sa
.
Column
(
'alt_token'
,
sa
.
Unicode
(
length
=
512
),
nullable
=
True
),
sa
.
Column
(
'token_secret'
,
sa
.
Unicode
(
length
=
512
),
nullable
=
True
),
sa
.
ForeignKeyConstraint
([
'local_user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_external_identities_local_user_id_users'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
PrimaryKeyConstraint
(
'external_id'
,
'local_user_id'
,
'provider_name'
,
name
=
'pk_external_identities'
),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'groups_permissions'
,
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'group_id'
],
[
'groups.id'
],
name
=
op
.
f
(
'fk_groups_permissions_group_id_groups'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
PrimaryKeyConstraint
(
'group_id'
,
'perm_name'
,
name
=
'pk_groups_permissions'
),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'res_dati2'
,
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'provinsi_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'provinsi_id'
],
[
'public.res_provinsi.id'
],
name
=
op
.
f
(
'fk_res_dati2_provinsi_id_res_provinsi'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_dati2'
)),
schema
=
'public'
)
op
.
create_table
(
'resources'
,
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
True
,
nullable
=
False
),
sa
.
Column
(
'parent_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'ordering'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'resource_name'
,
sa
.
Unicode
(
length
=
100
),
nullable
=
False
),
sa
.
Column
(
'resource_type'
,
sa
.
Unicode
(
length
=
30
),
nullable
=
False
),
sa
.
Column
(
'owner_group_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'owner_user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
ForeignKeyConstraint
([
'owner_group_id'
],
[
'groups.id'
],
name
=
op
.
f
(
'fk_resources_owner_group_id_groups'
),
onupdate
=
'CASCADE'
,
ondelete
=
'SET NULL'
),
sa
.
ForeignKeyConstraint
([
'owner_user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_resources_owner_user_id_users'
),
onupdate
=
'CASCADE'
,
ondelete
=
'SET NULL'
),
sa
.
ForeignKeyConstraint
([
'parent_id'
],
[
'resources.resource_id'
],
name
=
op
.
f
(
'fk_resources_parent_id_resources'
),
onupdate
=
'CASCADE'
,
ondelete
=
'SET NULL'
),
sa
.
PrimaryKeyConstraint
(
'resource_id'
,
name
=
op
.
f
(
'pk_resources'
)),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_index
(
op
.
f
(
'ix_resources_owner_group_id'
),
'resources'
,
[
'owner_group_id'
],
unique
=
False
)
op
.
create_index
(
op
.
f
(
'ix_resources_owner_user_id'
),
'resources'
,
[
'owner_user_id'
],
unique
=
False
)
op
.
create_table
(
'user_device'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'token'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'logged_in'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'las_login_date'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
True
),
sa
.
Column
(
'expired'
,
sa
.
DateTime
(
timezone
=
True
),
nullable
=
True
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_user_device_user_id_users'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_user_device'
))
)
op
.
create_table
(
'users_groups'
,
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'group_id'
],
[
'groups.id'
],
name
=
op
.
f
(
'fk_users_groups_group_id_groups'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_users_groups_user_id_users'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
PrimaryKeyConstraint
(
'group_id'
,
'user_id'
,
name
=
op
.
f
(
'pk_users_groups'
)),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'users_permissions'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_users_permissions_user_id_users'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
PrimaryKeyConstraint
(
'user_id'
,
'perm_name'
,
name
=
'pk_users_permissions'
),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'groups_resources_permissions'
,
sa
.
Column
(
'group_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
False
,
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
50
),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'group_id'
],
[
'groups.id'
],
name
=
op
.
f
(
'fk_groups_resources_permissions_group_id_groups'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
ForeignKeyConstraint
([
'resource_id'
],
[
'resources.resource_id'
],
name
=
op
.
f
(
'fk_groups_resources_permissions_resource_id_resources'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
PrimaryKeyConstraint
(
'group_id'
,
'resource_id'
,
'perm_name'
,
name
=
'pk_group_resources_permissions '
),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'res_kecamatan'
,
sa
.
Column
(
'ibu_kota'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'dati2_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'dati2_id'
],
[
'public.res_dati2.id'
],
name
=
op
.
f
(
'fk_res_kecamatan_dati2_id_res_dati2'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_kecamatan'
)),
schema
=
'public'
)
op
.
create_table
(
'users_resources_permissions'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'resource_id'
,
sa
.
Integer
(),
autoincrement
=
False
,
nullable
=
False
),
sa
.
Column
(
'perm_name'
,
sa
.
Unicode
(
length
=
64
),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'resource_id'
],
[
'resources.resource_id'
],
name
=
op
.
f
(
'fk_users_resources_permissions_resource_id_resources'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_users_resources_permissions_user_id_users'
),
onupdate
=
'CASCADE'
,
ondelete
=
'CASCADE'
),
sa
.
PrimaryKeyConstraint
(
'user_id'
,
'resource_id'
,
'perm_name'
,
name
=
'pk_users_resources_permissions '
),
mysql_charset
=
'utf8'
,
mysql_engine
=
'InnoDB'
)
op
.
create_table
(
'res_desa'
,
sa
.
Column
(
'kategori'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'kecamatan_id'
,
sa
.
SmallInteger
(),
nullable
=
True
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'kecamatan_id'
],
[
'public.res_kecamatan.id'
],
name
=
op
.
f
(
'fk_res_desa_kecamatan_id_res_kecamatan'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_res_desa'
)),
schema
=
'public'
)
op
.
create_table
(
'partner'
,
sa
.
Column
(
'kelurahan'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'kecamatan'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'kota'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'provinsi'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'rt'
,
sa
.
String
(
length
=
3
),
nullable
=
True
),
sa
.
Column
(
'rw'
,
sa
.
String
(
length
=
3
),
nullable
=
True
),
sa
.
Column
(
'tempat_lahir'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'tgl_lahir'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'jenis_kelamin'
,
sa
.
String
(
length
=
1
),
nullable
=
True
),
sa
.
Column
(
'gol_darah'
,
sa
.
String
(
length
=
2
),
nullable
=
True
),
sa
.
Column
(
'agama'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'perkawinan'
,
sa
.
String
(
length
=
2
),
nullable
=
True
),
sa
.
Column
(
'pekerjaan'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'kewarganegaraan'
,
sa
.
String
(
length
=
10
),
nullable
=
True
),
sa
.
Column
(
'provinsi_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'dati2_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'kecamatan_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'desa_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'company_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'nip'
,
sa
.
String
(
length
=
32
),
nullable
=
True
),
sa
.
Column
(
'idcard'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'status'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'alamat_1'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'alamat_2'
,
sa
.
String
(
length
=
128
),
nullable
=
True
),
sa
.
Column
(
'email'
,
sa
.
String
(
length
=
40
),
nullable
=
True
),
sa
.
Column
(
'phone'
,
sa
.
String
(
length
=
16
),
nullable
=
True
),
sa
.
Column
(
'fax'
,
sa
.
String
(
length
=
16
),
nullable
=
True
),
sa
.
Column
(
'mobile'
,
sa
.
String
(
length
=
16
),
nullable
=
True
),
sa
.
Column
(
'website'
,
sa
.
String
(
length
=
64
),
nullable
=
True
),
sa
.
Column
(
'is_vendor'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'is_customer'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'nama'
,
sa
.
String
(
length
=
128
),
nullable
=
False
),
sa
.
Column
(
'kode'
,
sa
.
String
(
length
=
32
),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'dati2_id'
],
[
'public.res_dati2.id'
],
name
=
op
.
f
(
'fk_partner_dati2_id_res_dati2'
)),
sa
.
ForeignKeyConstraint
([
'desa_id'
],
[
'public.res_desa.id'
],
name
=
op
.
f
(
'fk_partner_desa_id_res_desa'
)),
sa
.
ForeignKeyConstraint
([
'kecamatan_id'
],
[
'public.res_kecamatan.id'
],
name
=
op
.
f
(
'fk_partner_kecamatan_id_res_kecamatan'
)),
sa
.
ForeignKeyConstraint
([
'provinsi_id'
],
[
'public.res_provinsi.id'
],
name
=
op
.
f
(
'fk_partner_provinsi_id_res_provinsi'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_partner'
))
)
op
.
create_table
(
'user_area'
,
sa
.
Column
(
'user_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'desa_id'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'desa_id'
],
[
'public.res_desa.id'
],
name
=
op
.
f
(
'fk_user_area_desa_id_res_desa'
)),
sa
.
ForeignKeyConstraint
([
'user_id'
],
[
'users.id'
],
name
=
op
.
f
(
'fk_user_area_user_id_users'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_user_area'
))
)
op
.
create_table
(
'partner_files'
,
sa
.
Column
(
'partner_id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'file_name'
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
'description'
,
sa
.
String
(
length
=
256
),
nullable
=
True
),
sa
.
Column
(
'status'
,
sa
.
SmallInteger
(),
nullable
=
False
),
sa
.
Column
(
'created'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'updated'
,
sa
.
DateTime
(),
nullable
=
True
),
sa
.
Column
(
'create_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'update_uid'
,
sa
.
Integer
(),
nullable
=
True
),
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'partner_id'
],
[
'partner.id'
],
name
=
op
.
f
(
'fk_partner_files_partner_id_partner'
)),
sa
.
PrimaryKeyConstraint
(
'id'
,
name
=
op
.
f
(
'pk_partner_files'
))
)
op
.
drop_table
(
'alembic_version'
)
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
create_table
(
'alembic_version'
,
sa
.
Column
(
'version_num'
,
sa
.
VARCHAR
(
length
=
32
),
autoincrement
=
False
,
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
'version_num'
,
name
=
op
.
f
(
'alembic_version_pkc'
))
)
op
.
drop_table
(
'partner_files'
)
op
.
drop_table
(
'user_area'
)
op
.
drop_table
(
'partner'
)
op
.
drop_table
(
'res_desa'
,
schema
=
'public'
)
op
.
drop_table
(
'users_resources_permissions'
)
op
.
drop_table
(
'res_kecamatan'
,
schema
=
'public'
)
op
.
drop_table
(
'groups_resources_permissions'
)
op
.
drop_table
(
'users_permissions'
)
op
.
drop_table
(
'users_groups'
)
op
.
drop_table
(
'user_device'
)
op
.
drop_index
(
op
.
f
(
'ix_resources_owner_user_id'
),
table_name
=
'resources'
)
op
.
drop_index
(
op
.
f
(
'ix_resources_owner_group_id'
),
table_name
=
'resources'
)
op
.
drop_table
(
'resources'
)
op
.
drop_table
(
'res_dati2'
,
schema
=
'public'
)
op
.
drop_table
(
'groups_permissions'
)
op
.
drop_table
(
'external_identities'
)
op
.
drop_table
(
'users'
)
op
.
drop_table
(
'targets'
)
op
.
drop_table
(
'target_jenis'
)
op
.
drop_table
(
'routes'
)
op
.
drop_table
(
'res_provinsi'
,
schema
=
'public'
)
op
.
drop_table
(
'permissions'
,
schema
=
'public'
)
op
.
drop_table
(
'departemen'
,
schema
=
'public'
)
op
.
drop_table
(
'parameters'
)
op
.
drop_table
(
'logs'
)
op
.
drop_table
(
'holiday'
)
op
.
drop_table
(
'groups'
)
# ### end Alembic commands ###
opensipkd/base/alembic/versions/10a68b1510a6_.py
View file @
ca06063
...
...
@@ -11,7 +11,7 @@ from sqlalchemy.dialects import postgresql
import
sqlalchemy
as
sa
from
alembic
import
op
revision
=
'10a68b1510a6'
down_revision
=
None
down_revision
=
'021a8a342d5b'
branch_labels
=
None
depends_on
=
None
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment