Following these instructions, executing a generateChangeLog command on my existing PostgreSQL database, the resulting file contains no changeset tags. Maybe I misunderstood something, but I thought the modifications to the database up to this point (tables created, etc.) would be already summed up here, and this was the point of the "Make It Look Like You've Always Been Using Liquibase" option.
If this is not a correct assumption, and going forward if I make a modification directly to the database that I want to be described as a changeSet, how do I use the Liquibase command line to add these changesets to the file?
EDIT:
Here is an example of stepping through generateChangeLog and update:
./liquibase --driver=org.postgresql.Driver --classpath=postgresql-42.2.4.jar --changeLogFile=changelog1.xml --url="jdbc:postgresql://localhost:5432/my_database" --username=postgres --password=postgres --logLevel=debug generateChangeLog
Output:
DEBUG 7/20/18 8:15 PM: liquibase: Connected to postgres@jdbc:postgresql://localhost:5432/my_database
DEBUG 7/20/18 8:15 PM: liquibase: Setting auto-commit to false from true
DEBUG 7/20/18 8:15 PM: liquibase: Computed checksum for 1532117738554 as 2d79fcfb744a18b475eac6c1d1bd804d
DEBUG 7/20/18 8:15 PM: liquibase: Executing QUERY database command: SELECT c.relname AS SEQUENCE_NAME FROM pg_class c join pg_namespace on c.relnamespace = pg_namespace.oid WHERE c.relkind='S' AND nspname = 'public' AND c.oid not in (select d.objid FROM pg_depend d where d.refobjsubid > 0)
INFO 7/20/18 8:15 PM: liquibase: changelog1.xml does not exist, creating
DEBUG 7/20/18 8:15 PM: liquibase: MissingObjectChangeGenerator type order: liquibase.structure.core.Catalog liquibase.structure.core.Schema liquibase.structure.core.Sequence liquibase.structure.core.StoredProcedure liquibase.structure.core.Table liquibase.structure.core.Column liquibase.structure.core.PrimaryKey liquibase.structure.core.UniqueConstraint liquibase.structure.core.Index liquibase.structure.core.ForeignKey liquibase.structure.core.View
DEBUG 7/20/18 8:15 PM: liquibase: UnexpectedObjectChangeGenerator type order: liquibase.structure.core.Catalog liquibase.structure.core.ForeignKey liquibase.structure.core.Schema liquibase.structure.core.StoredProcedure liquibase.structure.core.UniqueConstraint liquibase.structure.core.View liquibase.structure.core.Table liquibase.structure.core.PrimaryKey liquibase.structure.core.Column liquibase.structure.core.Index liquibase.structure.core.Sequence
DEBUG 7/20/18 8:15 PM: liquibase: ChangedObjectChangeGenerator type order: liquibase.structure.core.Catalog liquibase.structure.core.ForeignKey liquibase.structure.core.Schema liquibase.structure.core.Sequence liquibase.structure.core.StoredProcedure liquibase.structure.core.Table liquibase.structure.core.Column liquibase.structure.core.PrimaryKey liquibase.structure.core.UniqueConstraint liquibase.structure.core.Index liquibase.structure.core.View Liquibase 'generateChangeLog' Successful
At this point in my local PostgreSQL server, my_database has 2 schemas, one named my_schema (containing 11 tables populated with data that my application is using) and the other named public. The public has no tables.
Running liquibase update:
./liquibase --driver=org.postgresql.Driver --classpath=postgresql-42.2.4.jar --changeLogFile=changelog1.xml --url="jdbc:postgresql://localhost:5432/my_database" --username=postgres --password=postgres --logLevel=debug update
Returns:
DEBUG 7/20/18 8:21 PM: liquibase: Connected to postgres@jdbc:postgresql://localhost:5432/my_database
DEBUG 7/20/18 8:21 PM: liquibase: Setting auto-commit to false from true
DEBUG 7/20/18 8:21 PM: liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 7/20/18 8:21 PM: liquibase: Create Database Lock Table DEBUG 7/20/18 8:21 PM: liquibase: Executing EXECUTE database command: CREATE TABLE public.databasechangeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITHOUT TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))
DEBUG 7/20/18 8:21 PM: liquibase: Created database lock table with name: public.databasechangeloglock
DEBUG 7/20/18 8:21 PM: liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 7/20/18 8:21 PM: liquibase: Initialize Database Lock Table
DEBUG 7/20/18 8:21 PM: liquibase: Executing EXECUTE database command: DELETE FROM public.databasechangeloglock
DEBUG 7/20/18 8:21 PM: liquibase: Executing EXECUTE database command: INSERT INTO public.databasechangeloglock (ID, LOCKED) VALUES (1, FALSE)
DEBUG 7/20/18 8:21 PM: liquibase: Executing QUERY database command: SELECT LOCKED FROM public.databasechangeloglock WHERE ID=1
DEBUG 7/20/18 8:21 PM: liquibase: Lock Database
DEBUG 7/20/18 8:21 PM: liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '10.0.2.15 (10.0.2.15)', LOCKGRANTED = '2018-07-20 20:21:26.650' WHERE ID = 1 AND LOCKED = FALSE INFO 7/20/18 8:21 PM: liquibase: Successfully acquired change log lock
DEBUG 7/20/18 8:21 PM: liquibase: Resolving XML entity name='null', publicId='null', baseURI='null', systemId='http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd'
DEBUG 7/20/18 8:21 PM: liquibase: Opening jar:file:/home/vagrant/Documents/liquibase.jar!/liquibase/parser/core/xml/dbchangelog-3.5.xsd as liquibase/parser/core/xml/dbchangelog-3.5.xsd
DEBUG 7/20/18 8:21 PM: liquibase: Computed checksum for 1532118089029 as cfbe2a0b147c646104f738103a68b2fd
DEBUG 7/20/18 8:21 PM: liquibase: Create Database Change Log Table
INFO 7/20/18 8:21 PM: liquibase: Creating database history table with name: public.databasechangelog
DEBUG 7/20/18 8:21 PM: liquibase: Executing EXECUTE database command: CREATE TABLE public.databasechangelog (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED TIMESTAMP WITHOUT TIME ZONE NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID VARCHAR(10))
DEBUG 7/20/18 8:21 PM: liquibase: Executing QUERY database command: select count(*) from public.databasechangelog
INFO 7/20/18 8:21 PM: liquibase: Reading from public.databasechangelog
DEBUG 7/20/18 8:21 PM: liquibase: Executing QUERY database command: SELECT * FROM public.databasechangelog ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
DEBUG 7/20/18 8:21 PM: liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 7/20/18 8:21 PM: liquibase: Release Database Lock
DEBUG 7/20/18 8:21 PM: liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 7/20/18 8:21 PM: liquibase: Successfully released change log lock
Liquibase Update Successful
Now under the Public schema, there are 2 tables, databasechangelog, and databasechangeloglock. databasechangelog is empty, but databasechangeloglock contains one row with id 1 and "locked boolean" col "FALSE".
generateChangeLog
command should result in a changeset file that contains all "changes" to create your existing DB. If it's empty something is wrong. – Jens