deis/deis — pull request #972 by bacongobbler (2014-05-14 19:12:53+00:00)
Title: feat(client): add apps:rename command

This allows users to modify their app names after having created
one.

There was not much to do on the client-side, but the server side
required a massive overhaul. Because you cannot modify `id` fields
once they are set, the App.id field has been moved over to App.name.
The `id` field is no longer present in the database. Instead, the
`uuid` field is preferred. For example, this is the table that will
be created in the database with this fix (generated with `./manage.py
sql api`):

```
CREATE TABLE "api_app" (
"uuid" uuid NOT NULL PRIMARY KEY,
"created" timestamp with time zone NOT NULL,
"updated" timestamp with time zone NOT NULL,
"owner_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
"name" varchar(64) NOT NULL UNIQUE,
"cluster_id" uuid NOT NULL REFERENCES "api_cluster" ("uuid") DEFERRABLE INITIALLY DEFERRED,
"structure" text NOT NULL
)
;
```

There was also a previous test in api/tests/test_app that checked
to ensure that the PATCH method was not allowed, so I repurposed
it to test appname changes.

The API call to modify app names is:

PATCH /api/apps/{appname} {new_name}

Which will return HTTP status 200, and the endpoint is no longer
available. You will be able to reach the app at /api/apps/{new_name}
moving forward.

BREAKING CHANGES: because the `id` field in the database is being
removed for apps, this is backwards incompatible with apps. Once
you migrate over to this change, you cannot roll back and you will
have to destroy all applications deployed across the cluster.

TESTING: Since this affects practically every aspect of app
management, running the integration test suite is recommended:

$ vagrant up
$ make pull
$ cd test
$ bundle exec rake

fixes #475