ciclos

commit b06931b0ca44acb7b3e576097c7ae27235e966b7

Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>

Add basic configuration table and seed with data

 src/alembic/versions/a848d1c82ba0_set_initial_configuration.py | 43 ++++
 src/alembic/versions/b80a277fdc89_create_configuration.py | 31 ++


diff --git a/src/alembic/versions/a848d1c82ba0_set_initial_configuration.py b/src/alembic/versions/a848d1c82ba0_set_initial_configuration.py
new file mode 100644
index 0000000000000000000000000000000000000000..c12414a228da4c7aea3e3bba347cb1294f6a8a47
--- /dev/null
+++ b/src/alembic/versions/a848d1c82ba0_set_initial_configuration.py
@@ -0,0 +1,43 @@
+"""set initial configuration
+
+Revision ID: a848d1c82ba0
+Revises: b80a277fdc89
+Create Date: 2020-01-14 01:03:35.088003
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'a848d1c82ba0'
+down_revision = 'b80a277fdc89'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+  op.execute("""
+    INSERT INTO configurations (
+      purchase_duration,
+      purchase_duration_type,
+      delivery_duration,
+      delivery_duration_type,
+      created_at,
+      updated_at
+    )
+    VALUES (
+      3.0,
+      'days',
+      2,
+      'hours',
+      NOW(),
+      NOW()
+    );
+  """)
+
+
+def downgrade():
+  op.execute("""
+    DELETE FROM configurations;
+  """)




diff --git a/src/alembic/versions/b80a277fdc89_create_configuration.py b/src/alembic/versions/b80a277fdc89_create_configuration.py
new file mode 100644
index 0000000000000000000000000000000000000000..0383dcde6f852b32ae68cc3111c67f94496e03fb
--- /dev/null
+++ b/src/alembic/versions/b80a277fdc89_create_configuration.py
@@ -0,0 +1,31 @@
+"""create configuration
+
+Revision ID: b80a277fdc89
+Revises: 1a8c88c6e1e4
+Create Date: 2020-01-14 00:52:43.495301
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'b80a277fdc89'
+down_revision = '1a8c88c6e1e4'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    op.create_table('configurations', 
+        sa.Column('id', sa.Integer, primary_key = True),
+        sa.Column('purchase_duration', sa.Float, nullable = False),
+        sa.Column('purchase_duration_type', sa.String(256), server_default = 'days'),
+        sa.Column('delivery_duration', sa.Float, nullable = False),
+        sa.Column('delivery_duration_type', sa.String(256), server_default = 'days'),
+        sa.Column('created_at', sa.DateTime),
+        sa.Column('updated_at', sa.DateTime)
+    )
+
+def downgrade():
+    op.drop_table('configurations')