You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

1 Días
20 Hrs
48 Min
14 Seg
Curso de Java Spring

Curso de Java Spring

Alejandro Ramírez

Alejandro Ramírez

Desplegar nuestra base de datos con Heroku

33/35
Resources

How does the removal of Heroku's free tier affect Heroku?

As of November 28, 2022, Heroku announced significant changes to its pricing structure, eliminating the free tier that many developers used to deploy their applications. The new policy requires registering at least one credit card to access its services. This implies that developers must now look for free alternatives to host their applications and databases or consider using other cloud platforms such as Amazon, Azure, or Digital Ocean, where the terms of use may be different.

How to deploy using Heroku?

For those who prefer to continue using Heroku, it is still possible to deploy applications, albeit under the new pricing policy. Here's how to do it.

What do you need before you start?

  • Heroku account: Make sure you have an active account.
  • Heroku CLI: It must be installed on your machine. This command line tool is essential for deployment.

Once ready, go to the root of your project from the command window and follow the instructions below.

How to log in and create an application in Heroku?

First, you need to be in the root of your project and login with the heroku login command. This step opens a window in your browser where you can login with your Heroku email and password. After the login, you can go back to the CLI and start the deployment process.

Once you have successfully logged in, you can create a new empty application with the command:

heroku create your_app_name

For example, if your application is called "clatzi_Market", the command would be:

heroku create clatzi_Market

How to add a PostgreSQL database?

Most applications require a database to run. Heroku makes it easy to add this with an addon:

heroku addons:create heroku-postgresql.

This command will create and configure a free PostgreSQL database.

How to configure PGAdmin to connect to the database?

To manage the database, using PGAdmin is a popular choice. Set up the connection like this:

  1. Open PGAdmin and create a new server in the left menu.
  2. Name the server "Heroku".
  3. In the connection tab, enter the necessary details you got from the heroku config command, specifically:
    • Host Name or Address: Part of the URL before the colon (:) that indicates the port.
    • Port: Default is 5432.
    • Database Name: Located after the port.
    • User and Password: Part of the connection URL obtained from the same command.

How to adjust the application properties for deployment?

Finally, adjust the application.properties file in your project so it can work in Heroku. Heroku uses environment variables to set these properties. The file might look something like this:

spring.datasource.url=$${DATABASE_URL}spring.datasource.username=${DATABASE_USERNAME}spring.datasource.password=${DATABASE_PASSWORD}

With all this configured, your application is ready for deployment on Heroku. Don't forget to always check the connection details and environment variables to ensure everything works optimally.

The development world is always evolving. Don't be discouraged by changes, but take advantage of them to learn new skills and explore different platforms - keep going on your cloud learning journey!

Contributions 18

Questions 5

Sort by:

Want to see more contributions, questions and answers from the community?

En windows adicionalmente realice la siguiente configuración para asociar el repositorio a Heroku, de lo contrario no funcionaba $heroku config, platziapp es el nombre del proyecto en heroku

$ heroku git:remote -a platziapp

Si les dice el error:

Error: Missing required flag:

coloquen:

heroku git:remote -a nombreDeProyecto

Heroku ya no permite crear proyectos sin antes agregar un metodo de pago.

Para los que no tienen instalado el pgadmin y quieren conectarse desde el CLI a postgresql.

sudo psql -h <HOST> -U <USER_NAME>-<DATABASE_NAME> -p <PUERTO>

– CATEGORIAS
INSERT INTO categorias VALUES (1, ‘Frutas y verduras’, true);
INSERT INTO categorias VALUES (2, ‘Pastelería’, true);
INSERT INTO categorias VALUES (3, ‘Carnes y pescados’, true);
INSERT INTO categorias VALUES (4, ‘Lácteos y huevos’, true);
INSERT INTO categorias VALUES (5, ‘Bebidas’, true);
INSERT INTO categorias VALUES (6, ‘Licores’, true);
INSERT INTO categorias VALUES (7, ‘Cuidado personal’, true);
INSERT INTO categorias VALUES (8, ‘Despensa’, true);

– PRODUCTOS
INSERT INTO productos VALUES (1, ‘Guayaba Feijoa’, 1, ‘7029 A42 23’, 300, 500, true);
INSERT INTO productos VALUES (2, ‘Mango’, 1, ‘0316 R56 01’, 2100, 250, true);
INSERT INTO productos VALUES (3, ‘Manzana’, 1, ‘7923 T23 19’, 700, 130, true);
INSERT INTO productos VALUES (4, ‘Aguacate’, 1, ‘9322 Q33 02’, 2500, 98, true);
INSERT INTO productos VALUES (5, ‘Lechuga’, 1, ‘9742 S22 21’, 4000, 86, true);
INSERT INTO productos VALUES (6, ‘Tomate’, 1, ‘0483 R00 97’, 290, 430, true);
INSERT INTO productos VALUES (7, ‘Pera’, 1, ‘9999 X10 01’, 750, 210, true);
INSERT INTO productos VALUES (8, ‘Apio’, 1, ‘3390 F29 45’, 150, 115, true);
INSERT INTO productos VALUES (9, ‘Papaya’, 1, ‘5291 J34 32’, 4500, 73, true);
INSERT INTO productos VALUES (10, ‘Limón’, 1, ‘7886 N18 32’, 350, 425, true);
INSERT INTO productos VALUES (11, ‘Brownie’, 2, ‘6683 H15 20’, 2500, 80, true);
INSERT INTO productos VALUES (12, ‘Pan tajado’, 2, ‘5745 F05 47’, 4500, 120, true);
INSERT INTO productos VALUES (13, ‘Torta’, 2, ‘3831 D97 99’, 10000, 35, true);
INSERT INTO productos VALUES (14, ‘Tortilla’, 2, ‘4335 Z33 84’, 6400, 87, true);
INSERT INTO productos VALUES (15, ‘Tostadas’, 2, ‘6584 M19 25’, 4000, 45, true);
INSERT INTO productos VALUES (16, ‘Chocorramo’, 2, ‘4487 S00 97’, 2000, 105, true);
INSERT INTO productos VALUES (17, ‘Salmón’, 3, ‘4546 A00 01’, 28000, 55, true);
INSERT INTO productos VALUES (18, ‘Punta de anca’, 3, ‘3678 E57 22’, 12000, 32, true);
INSERT INTO productos VALUES (19, ‘Posta’, 3, ‘8893 O01 03’, 7800, 40, true);
INSERT INTO productos VALUES (20, ‘Costilla de cerdo’, 3, ‘4534 Q12 88’, 8600, 70, true);
INSERT INTO productos VALUES (21, ‘Tilapia’, 3, ‘5684 R53 02’, 17000, 60, true);
INSERT INTO productos VALUES (22, ‘Merluza’, 3, ‘3523 R04 00’, 23000, 45, true);
INSERT INTO productos VALUES (23, ‘Leche de vaca’, 4, ‘2323 T56 33’, 2500, 500, true);
INSERT INTO productos VALUES (24, ‘Queso’, 4, ‘7786 K19 56’, 4000, 300, true);
INSERT INTO productos VALUES (25, ‘Huevos de gallina feliz’, 4, ‘3478 M74 01’, 400, 1000, true);
INSERT INTO productos VALUES (26, ‘Clara de huevo’, 4, ‘7932 R31 46’, 3200, 200, true);
INSERT INTO productos VALUES (27, ‘Suero costeño’, 4, ‘5463 W23 33’, 9000, 110, true);
INSERT INTO productos VALUES (28, ‘Agua’, 5, ‘8965 I32 11’, 2000, 600, true);
INSERT INTO productos VALUES (29, ‘Jugo de naranja’, 5, ‘7445 T87 44’, 7400, 200, true);
INSERT INTO productos VALUES (30, ‘Gaseosa Colombiana’, 5, ‘3434 R34 63’, 3100, 175, true);
INSERT INTO productos VALUES (31, ‘Jugo de Lulo’, 5, ‘9753 W33 19’, 8250, 630, true);
INSERT INTO productos VALUES (32, ‘Tea’, 5, ‘9836 F35 69’, 1900, 450, true);
INSERT INTO productos VALUES (33, ‘Cerveza’, 6, ‘3432 G67 21’, 2100, 800, true);
INSERT INTO productos VALUES (34, ‘Tequila’, 6, ‘9529 E45 98’, 65000, 764, true);
INSERT INTO productos VALUES (35, ‘Ron’, 6, ‘1947 R07 53’, 55000, 240, true);
INSERT INTO productos VALUES (36, ‘Aguardiente Antioqueño’, 6, ‘3160 A54 94’, 40000, 480, true);
INSERT INTO productos VALUES (37, ‘Vino’, 6, ‘7891 W46 95’, 82000, 560, true);
INSERT INTO productos VALUES (38, ‘Crema dental’, 7, ‘6310 C99 73’, 7500, 200, true);
INSERT INTO productos VALUES (39, ‘Jabón de manos’, 7, ‘9371 J14 75’, 4900, 90, true);
INSERT INTO productos VALUES (40, ‘Enjuague bucal’, 7, ‘1942 T68 01’, 12000, 105, true);
INSERT INTO productos VALUES (41, ‘Shampoo’, 7, ‘6789 W01 23’, 9300, 200, true);
INSERT INTO productos VALUES (42, ‘Desodorante’, 7, ‘7333 S21 36’, 6900, 85, true);
INSERT INTO productos VALUES (43, ‘Arroz’, 8, ‘4676 I83 00’, 3500, 600, true);
INSERT INTO productos VALUES (44, ‘Lentejas’, 8, ‘7333 S21 36’, 3000, 560, true);
INSERT INTO productos VALUES (45, ‘Harina’, 8, ‘7333 S21 36’, 1800, 300, true);
INSERT INTO productos VALUES (46, ‘Sal’, 8, ‘7333 S21 36’, 1400, 500, true);
INSERT INTO productos VALUES (47, ‘Aceite’, 8, ‘7333 S21 36’, 6500, 135, true);
INSERT INTO productos VALUES (48, ‘Cereal’, 8, ‘4673 K53 98’, 7000, 75, true);
INSERT INTO productos VALUES (49, ‘Frijol’, 8, ‘2745 F40 45’, 8200, 270, true);
INSERT INTO productos VALUES (50, ‘Café’, 8, ‘6351 R33 92’, 7200, 400, true);

– CLIENTES
INSERT INTO clientes VALUES (‘4546221’, ‘Johannes’, ‘Kepler’, 3104583224, ‘Cl 3 # 33 - 33’, ‘[email protected]’);
INSERT INTO clientes VALUES (‘2552243’, ‘Galileo’, ‘Galilei’, 3462257293, ‘Cl 1 # 11 - 11’, ‘[email protected]’);
INSERT INTO clientes VALUES (‘983824’, ‘Nicolás’, ‘Copernico’, 3019392466, ‘Cl 2 # 22 - 22’, ‘[email protected]’);

– COMPRA
INSERT INTO compras VALUES (1, ‘4546221’, TO_TIMESTAMP(‘10/08/1992 17:30:00’,‘DD/MM/YYYY HH24:MI:SS’), ‘E’, ‘’, ‘P’);
INSERT INTO compras_productos VALUES (1, 1, 10, 3000, true);
INSERT INTO compras_productos VALUES (1, 36, 1, 40000, true);
INSERT INTO compras_productos VALUES (1, 27, 1, 9000, true);
INSERT INTO compras_productos VALUES (1, 49, 2, 16400, true);
INSERT INTO compras_productos VALUES (1, 24, 1, 4000, true);

– SE REINICIAN LAS SECUENCIAS SEGÚN LOS DATOS INICIALES
SELECT setval(‘public.productos_id_producto_seq’, 50, true);
SELECT setval(‘public.categorias_id_categoria_seq’, 8, true);
SELECT setval(‘public.compras_id_compra_seq’, 1, true);


– Table “CATEGORIAS”


CREATE TABLE CATEGORIAS (
“id_categoria” SERIAL NOT NULL,
“descripcion” VARCHAR(45) NOT NULL,
“estado” BOOLEAN NOT NULL,
PRIMARY KEY (“id_categoria”));


– Table “PRODUCTOS”


CREATE TABLE PRODUCTOS (
“id_producto” SERIAL NOT NULL,
“nombre” VARCHAR(45) NULL,
“id_categoria” INT NOT NULL,
“codigo_barras” VARCHAR(150) NULL,
“precio_venta” DECIMAL(16,2) NULL,
“cantidad_stock” INT NOT NULL,
“estado” BOOLEAN NULL,
PRIMARY KEY (“id_producto”),
CONSTRAINT "fk_PRODUCTOS_CATEGORIAS"
FOREIGN KEY (“id_categoria”)
REFERENCES CATEGORIAS (“id_categoria”)
ON DELETE NO ACTION
ON UPDATE NO ACTION);


– Table “CLIENTES”


CREATE TABLE CLIENTES (
“id” VARCHAR(20) NOT NULL,
“nombre” VARCHAR(40) NULL,
“apellidos” VARCHAR(100) NULL,
“celular” NUMERIC NULL,
“direccion” VARCHAR(80) NULL,
“correo_electronico” VARCHAR(70) NULL,
PRIMARY KEY (“id”));


– Table “COMPRAS”


CREATE TABLE COMPRAS (
“id_compra” SERIAL NOT NULL,
“id_cliente” VARCHAR(20) NOT NULL,
“fecha” TIMESTAMP NULL,
“medio_pago” CHAR(1) NULL,
“comentario” VARCHAR(300) NULL,
“estado” CHAR(1) NULL,
PRIMARY KEY (“id_compra”),
CONSTRAINT "fk_COMPRAS_CLIENTES1"
FOREIGN KEY (“id_cliente”)
REFERENCES CLIENTES (“id”)
ON DELETE NO ACTION
ON UPDATE NO ACTION);


– Table “COMPRAS_PRODUCTOS”


CREATE TABLE COMPRAS_PRODUCTOS (
“id_compra” INT NOT NULL,
“id_producto” INT NOT NULL,
“cantidad” INT NULL,
“total” DECIMAL(16,2) NULL,
“estado” BOOLEAN NULL,
PRIMARY KEY (“id_compra”, “id_producto”),
CONSTRAINT "fk_COMPRAS_PRODUCTOS_PRODUCTOS1"
FOREIGN KEY (“id_producto”)
REFERENCES PRODUCTOS (“id_producto”)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT "fk_COMPRAS_PRODUCTOS_COMPRAS1"
FOREIGN KEY (“id_compra”)
REFERENCES COMPRAS (“id_compra”)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

Buen curso, me parece que podría reemplazar completamente el Curso de Spring Boot. Hice los dos.

Para que no tengan que buscar la bd siempre , al crear el server van a

advanced
en DB restriction pegan el nombre de la bd
y dan en save
asi solo les aparecera su db , y no tendrar que buscarla cuando la tengan que gestionar
😃

Que grande con la cami de Kase.O ya solo por eso el curso merece la pena!

Buenas, debido a que heroku ya no es gratis me puse a hacer todo en AWS, la conexión del IDE Dbeaver que estoy utilizando y AWS la hizo correctamente, pero cuando quiero configurar el modo de producción no me lo permite, me dice que no existe la url, sin embargo cuando pongo una contraseña incorrecta, me indica que está mal, por tanto entiendo que está logrando llegar a la url, me podrian ayudar? gracias.

Para instalar Heroku: npm install -g heroku
En caso de que de un error de “command not found: heroku”

server.port=${PORT}

Database

spring.datasource.url=${SPRING_DATASOURCE_URL}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}

Generar dump

pg_dump  -h localhost -p 5432 -U postgres market  > market.bak   

Restaurar en heroku

psql -h "host de heroku" -p 5432 -U "Usuario de heroku" -d "Nombre de base de datos" -f "market.bak"

Tuve problemas con power shell después que cree el app en heroku lo solucione con el siguiente comando git inity luego heroku git:remote -a miproyecto.

Para la BD Postgresql, pueden usar render <https://render.com/>
Que bien que lo hayan actualizado! 😄

Muy útil la data. Digo.