| 39 | | self._deployed_unit = box.unit(DeployedVersion, ID=self.guid) |
|---|
| 40 | | if self._deployed_unit is None: |
|---|
| 41 | | self._deployed_unit = DeployedVersion(ID=self.guid, Version=0) |
|---|
| 42 | | box.memorize(self._deployed_unit) |
|---|
| | 39 | du = box.unit(DeployedVersion, ID=self.guid) |
|---|
| | 40 | if du is None: |
|---|
| | 41 | if default is None: |
|---|
| | 42 | raise errors.DejavuError("Missing DeployedVersion unit.") |
|---|
| | 43 | else: |
|---|
| | 44 | du = DeployedVersion(ID=self.guid, Version=default) |
|---|
| | 45 | box.memorize(du) |
|---|
| | 46 | self._deployed_unit = du |
|---|
| 46 | | return self._get_deployed_unit().Version |
|---|
| | 55 | # Note that we default the Version to latest. |
|---|
| | 56 | # This allows new installs to skip all the upgrade steps, |
|---|
| | 57 | # and just use the latest class definitions when they call |
|---|
| | 58 | # assert_storage. However, it means that if you deploy your |
|---|
| | 59 | # apps for a while without a Schema, and then introduce one |
|---|
| | 60 | # later, you must manually decrement DeployedVersion from |
|---|
| | 61 | # "latest" to the actual deployed version *before* running |
|---|
| | 62 | # your app for the first time (or things will break due to |
|---|
| | 63 | # the difference between the latest and deployed schema). |
|---|
| | 64 | return self.deployed_unit(self.latest).Version |
|---|
| 73 | | def upgrade_to_1(self): |
|---|
| | 94 | def assert_storage(self): |
|---|
| | 95 | """Assert that each class has storage reserved for it. |
|---|
| | 96 | |
|---|
| | 97 | You may choose to call this method in an admin script (at the |
|---|
| | 98 | discretion of the deployer), or on application startup. If you |
|---|
| | 99 | call this method on every application start, you should do it |
|---|
| | 100 | after calling upgrade(). Once all of the upgrade methods are done, |
|---|
| | 101 | you can then safely use this method to assert the _final_ schemas |
|---|
| | 102 | for all classes. Note that, if the DeployedVersion unit was just |
|---|
| | 103 | created (our actual deployed version was unknown), then some of |
|---|
| | 104 | the upgrade methods may fail. However, they could fail just as |
|---|
| | 105 | easily if you run assert_storage before the upgrade methods. |
|---|
| | 106 | """ |
|---|
| | 107 | |
|---|