1 """Peewee migrations -- 001_initial.py.
3 Some examples (model - class or model name)::
5 > Model = migrator.orm['model_name'] # Return model in current state by name
7 > migrator.sql(sql) # Run custom SQL
8 > migrator.python(func, *args, **kwargs) # Run python code
9 > migrator.create_model(Model) # Create a model (could be used as decorator)
10 > migrator.remove_model(model, cascade=True) # Remove a model
11 > migrator.add_fields(model, **fields) # Add fields to a model
12 > migrator.change_fields(model, **fields) # Change fields
13 > migrator.remove_fields(model, *field_names, cascade=True)
14 > migrator.rename_field(model, old_field_name, new_field_name)
15 > migrator.rename_table(model, new_table_name)
16 > migrator.add_index(model, *col_names, unique=False)
17 > migrator.drop_index(model, *col_names)
18 > migrator.add_not_null(model, *field_names)
19 > migrator.drop_not_null(model, *field_names)
20 > migrator.add_default(model, field_name, default)
29 def migrate(migrator
, database
, fake
=False, **kwargs
):
30 """Write your migrations here."""
32 @migrator.create_model
33 class Alarm(pw
.Model
):
35 uuid
= pw
.CharField(max_length
=255, unique
=True)
36 name
= pw
.CharField(max_length
=255)
37 severity
= pw
.CharField(max_length
=255)
38 threshold
= pw
.FloatField()
39 operation
= pw
.CharField(max_length
=255)
40 statistic
= pw
.CharField(max_length
=255)
41 monitoring_param
= pw
.CharField(max_length
=255)
42 vdur_name
= pw
.CharField(max_length
=255)
43 vnf_member_index
= pw
.CharField(max_length
=255)
44 nsr_id
= pw
.CharField(max_length
=255)
49 @migrator.create_model
50 class BaseModel(pw
.Model
):
54 table_name
= "basemodel"
56 @migrator.create_model
57 class VimCredentials(pw
.Model
):
59 uuid
= pw
.CharField(max_length
=255, unique
=True)
60 name
= pw
.CharField(max_length
=255)
61 type = pw
.CharField(max_length
=255)
62 url
= pw
.CharField(max_length
=255)
63 user
= pw
.CharField(max_length
=255)
64 password
= pw
.CharField(max_length
=255)
65 tenant_name
= pw
.CharField(max_length
=255)
66 config
= pw
.TextField()
69 table_name
= "vimcredentials"
72 def rollback(migrator
, database
, fake
=False, **kwargs
):
73 """Write your rollback migrations here."""
75 migrator
.remove_model('vimcredentials')
77 migrator
.remove_model('basemodel')
79 migrator
.remove_model('alarm')