Ver código fonte

:sparkles: added zip code seed data and migrations

tags/0.0.1
J 4 anos atrás
pai
commit
f76acb59d0

+ 14
- 0
backend/db/migrations/20210929163630_zipcodes.js Ver arquivo

@@ -0,0 +1,14 @@
1
+exports.up = function (knex) {
2
+    return knex.schema.createTable('zip_codes', function (table) {
3
+        table.integer('zip_code_id').primary()
4
+        table.string('latitude', 16).notNullable()
5
+        table.string('longitude', 16).notNullable()
6
+        table.string('city', 128).notNullable()
7
+        table.string('state', 16).notNullable()
8
+        table.string('county', 128).notNullable()
9
+    })
10
+}
11
+
12
+exports.down = function (knex) {
13
+    return knex.schema.dropTable('zip_codes')
14
+}

+ 11
- 0
backend/db/seeds/08-zipcodes.js Ver arquivo

@@ -0,0 +1,11 @@
1
+const zips = require('../zipcodes')
2
+
3
+exports.seed = function (knex) {
4
+    // Deletes ALL existing entries
5
+    return knex('zip_codes')
6
+        .truncate()
7
+        .then(function () {
8
+            // Inserts seed entries
9
+            return knex('zip_codes').insert(zips)
10
+        })
11
+}

+ 341930
- 0
backend/db/zipcodes.js
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


Carregando…
Cancelar
Salvar