README.md in pgslice-0.1.1 vs README.md in pgslice-0.1.2
- old
+ new
@@ -82,9 +82,69 @@
```sh
pgslice unswap <table>
```
+## Sample Output
+
+`pgslice` prints the SQL commands that were executed on the server. To print without executing, use the `--dry-run` option.
+
+```console
+$ pgslice prep locations created_at day
+BEGIN;
+
+CREATE TABLE locations_intermediate (
+ LIKE locations INCLUDING INDEXES INCLUDING DEFAULTS
+);
+
+CREATE FUNCTION locations_insert_trigger()
+RETURNS trigger AS $$
+BEGIN
+ EXECUTE 'INSERT INTO public.locations_' || to_char(NEW.created_at, 'YYYYMMDD') || ' VALUES ($1.*)' USING NEW;
+ RETURN NULL;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER locations_insert_trigger
+BEFORE INSERT ON locations_intermediate
+FOR EACH ROW EXECUTE PROCEDURE locations_insert_trigger();
+
+COMMIT;
+```
+
+```console
+$ pgslice add_partitions locations --intermediate --past 1 --future 1
+BEGIN;
+
+CREATE TABLE locations_20160423 (
+ LIKE locations_intermediate INCLUDING INDEXES INCLUDING DEFAULTS,
+ CHECK (created_at >= '2016-04-23'::date AND created_at < '2016-04-24'::date)
+) INHERITS (locations_intermediate);
+
+CREATE TABLE locations_20160424 (
+ LIKE locations_intermediate INCLUDING INDEXES INCLUDING DEFAULTS,
+ CHECK (created_at >= '2016-04-24'::date AND created_at < '2016-04-25'::date)
+) INHERITS (locations_intermediate);
+
+CREATE TABLE locations_20160425 (
+ LIKE locations_intermediate INCLUDING INDEXES INCLUDING DEFAULTS,
+ CHECK (created_at >= '2016-04-25'::date AND created_at < '2016-04-26'::date)
+) INHERITS (locations_intermediate);
+
+COMMIT;
+```
+
+```console
+$ pgslice swap locations
+BEGIN;
+
+ALTER TABLE locations RENAME TO locations_retired;
+
+ALTER TABLE locations_intermediate RENAME TO locations;
+
+COMMIT;
+```
+
## Upgrading
Run:
```sh